blob: 4e1fda82229ffcbae7732603ed9cc069a17c32e0 [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 }
93
94 return skip;
95}
96
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060097bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
Mike Schuchardtc57de4a2021-07-20 17:26:32 -070098 if (instance_extensions.vk_khr_get_physical_device_properties2) {
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060099 // Struct is legal IF it's supported
100 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
101 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
102 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
103 if (enum_iter != dev_exts_enumerated->second.cend()) {
104 return true;
105 }
106 }
107 return false;
108}
109
Tony-LunarG866843d2020-05-13 11:22:42 -0600110bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
111 const VkValidationFeaturesEXT *validation_features) const {
112 bool skip = false;
113 bool debug_printf = false;
114 bool gpu_assisted = false;
115 bool reserve_slot = false;
116 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
117 switch (validation_features->pEnabledValidationFeatures[i]) {
118 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
119 gpu_assisted = true;
120 break;
121
122 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
123 debug_printf = true;
124 break;
125
126 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
127 reserve_slot = true;
128 break;
129
130 default:
131 break;
132 }
133 }
134 if (reserve_slot && !gpu_assisted) {
135 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
136 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
137 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
138 }
139 if (gpu_assisted && debug_printf) {
140 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
141 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
142 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
143 }
144
145 return skip;
146}
147
John Zulauf620755c2018-04-16 11:00:43 -0600148template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700149ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
150 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600151 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700152 ExtEnabled state =
153 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600154 return state;
155}
156
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700157bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500158 const VkAllocationCallbacks *pAllocator,
159 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700160 bool skip = false;
161 // Note: From the spec--
162 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
163 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
164 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700165 ? pCreateInfo->pApplicationInfo->apiVersion
166 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700167 skip |= validate_api_version(local_api_version, api_version);
168 skip |= validate_instance_extensions(pCreateInfo);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700169 const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
Tony-LunarG866843d2020-05-13 11:22:42 -0600170 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
171
Tony-LunarG115f89d2022-06-15 10:53:22 -0600172#ifdef VK_USE_PLATFORM_METAL_EXT
173 auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pCreateInfo->pNext);
174 while (export_metal_object_info) {
175 if ((export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT) &&
176 (export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT)) {
177 skip |= LogError(instance, "VUID-VkInstanceCreateInfo-pNext-06779",
178 "vkCreateInstance(): The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose "
179 "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of "
180 "VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT or "
181 "VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT are allowed",
182 string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType));
183 }
184 export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext);
185 }
186#endif // VK_USE_PLATFORM_METAL_EXT
187
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700188 return skip;
189}
190
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700191void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700192 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
193 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700194 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
195 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700196 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700197 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700198}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600199
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700200void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
201 // Assume phys_devices is valid
202 assert(phys_devices);
203 for (int i = 0; i < count; ++i) {
204 const auto &phys_device = phys_devices[i];
205 if (0 == physical_device_properties_map.count(phys_device)) {
206 auto phys_dev_props = new VkPhysicalDeviceProperties;
207 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
208 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600209
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700210 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
211 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700212 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700213 std::vector<VkExtensionProperties> ext_props{};
214 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
215 ext_props.resize(ext_count);
216 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
217 for (uint32_t j = 0; j < ext_count; j++) {
218 dev_exts_enumerated.insert(ext_props[j].extensionName);
219 }
220 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600221 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700222 }
223}
224
225void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
226 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
227 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
228 return;
229 }
230
231 if (pPhysicalDeviceCount && pPhysicalDevices) {
232 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
233 }
234}
235
236void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
237 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
238 VkResult result) {
239 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
240 return;
241 }
242
243 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
244 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
245 const auto &group = pPhysicalDeviceGroupProperties[i];
246 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
247 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600248 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700249}
250
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600251void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
252 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
253 delete (it->second);
254 it = physical_device_properties_map.erase(it);
255 }
256};
257
ziga-lunarg685d5d62022-05-14 00:38:06 +0200258
259void StatelessValidation::GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
260 VkPhysicalDeviceProperties2 &pProperties) const {
261 if (api_version >= VK_API_VERSION_1_1) {
262 DispatchGetPhysicalDeviceProperties2(physicalDevice, &pProperties);
263 } else if (IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) {
264 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &pProperties);
265 }
266}
267
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700268void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700269 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700270 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700271 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700272 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
273 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700274
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700275 // Parmeter validation also uses extension data
276 stateless_validation->device_extensions = this->device_extensions;
277
278 VkPhysicalDeviceProperties device_properties = {};
279 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600280 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700281 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
282
sfricke-samsung45996a42021-09-16 13:45:27 -0700283 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700284 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700285 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
286 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200287 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700288 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
289 }
290
sfricke-samsung45996a42021-09-16 13:45:27 -0700291 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700292 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700293 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
294 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200295 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700296 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
297 }
298
sfricke-samsung45996a42021-09-16 13:45:27 -0700299 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700300 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700301 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
302 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200303 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500304 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
305 }
306
sfricke-samsung45996a42021-09-16 13:45:27 -0700307 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500308 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700309 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
310 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200311 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500312 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700313 }
314
sfricke-samsung45996a42021-09-16 13:45:27 -0700315 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700316 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700317 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
318 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200319 GetPhysicalDeviceProperties2(physicalDevice, prop2);
sourav parmarcd5fb182020-07-17 12:58:44 -0700320 phys_dev_ext_props.acc_structure_props = acc_structure_props;
321 }
322
sfricke-samsung45996a42021-09-16 13:45:27 -0700323 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700324 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700325 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
326 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200327 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700328 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
329 }
330
sfricke-samsung45996a42021-09-16 13:45:27 -0700331 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600332 // Get the needed vertex attribute divisor limits
333 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
334 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200335 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Piers Daniellcb6d8032021-04-19 18:51:26 -0600336 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
337 }
338
sfricke-samsung45996a42021-09-16 13:45:27 -0700339 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
Piers Daniella7f93b62021-11-20 12:32:04 -0700340 // Get the needed blend operation advanced properties
ziga-lunarga283d022021-08-04 18:35:23 +0200341 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
342 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200343 GetPhysicalDeviceProperties2(physicalDevice, prop2);
ziga-lunarga283d022021-08-04 18:35:23 +0200344 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
345 }
346
Piers Daniella7f93b62021-11-20 12:32:04 -0700347 if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) {
348 // Get the needed maintenance4 properties
349 auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>();
350 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200351 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Piers Daniella7f93b62021-11-20 12:32:04 -0700352 phys_dev_ext_props.maintenance4_props = maintance4_props;
353 }
354
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800355 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
356
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700357 // Save app-enabled features in this device's validation object
358 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700359 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200360 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
361 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
362 if (features2) {
363 tmp_features2_state.features = features2->features;
364 } else if (pCreateInfo->pEnabledFeatures) {
365 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700366 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200367 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700368 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200369 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700370 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200371 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700372}
373
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700374bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500375 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600376 bool skip = false;
377
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200378 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
379 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
380 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600381 }
382
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700383 // If this device supports VK_KHR_portability_subset, it must be enabled
384 const std::string portability_extension_name("VK_KHR_portability_subset");
385 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
386 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
387 bool portability_requested = false;
388
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200389 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
390 skip |=
391 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
392 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
393 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
394 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700395 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
396 portability_requested = true;
397 }
398 }
399
400 if (portability_supported && !portability_requested) {
401 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
402 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
403 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600404 }
405
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200406 {
aitor-lunargd5301592022-01-05 22:38:16 +0100407 bool maint1 = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700408 bool negative_viewport =
aitor-lunargd5301592022-01-05 22:38:16 +0100409 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
410 if (negative_viewport) {
411 // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to
412 // integration into api version 1.1
413 if (api_version >= VK_API_VERSION_1_1) {
414 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840",
415 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not include "
416 "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1.");
417 } else if (maint1) {
418 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
419 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include "
420 "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height.");
421 }
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200422 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600423 }
424
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600425 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200426 bool khr_bda =
427 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
428 bool ext_bda =
429 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600430 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700431 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
432 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
433 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600434 }
435 }
436
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600437 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
438 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700439 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600440 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800441 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700442 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800443 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700444 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600445 }
446 }
447
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700448 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500449 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700450 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500451 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
452 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
453 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
454 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700455 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700456 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
457 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
458 skip |= LogError(
459 device,
460 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
461 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
462 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700463 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700464 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700465 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600466 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
467 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
468 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600469 }
470
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700471 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700472 if (vulkan_11_features) {
473 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
474 while (current) {
475 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
476 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
477 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
478 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
479 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
480 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700481 skip |= LogError(
482 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700483 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
484 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
485 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
486 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
487 break;
488 }
489 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
490 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800491
492 // Check features are enabled if matching extension is passed in as well
493 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
494 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
495 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
496 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
497 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800498 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476",
sfricke-samsungebda6792021-01-16 08:57:52 -0800499 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
500 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
501 }
502 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700503 }
504
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700505 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700506 if (vulkan_12_features) {
507 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
508 while (current) {
509 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
510 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
511 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
512 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
513 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
514 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
515 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
516 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
517 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
518 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
519 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
520 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
521 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700522 skip |= LogError(
523 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700524 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
525 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
526 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
527 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
528 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
529 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
530 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
531 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
532 break;
533 }
534 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
535 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700536 // Check features are enabled if matching extension is passed in as well
537 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
538 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
539 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
540 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
541 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800542 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831",
sfricke-samsungabab4632020-05-04 06:51:46 -0700543 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
544 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
545 }
546 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
547 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
Mike Schuchardt9969d022021-12-20 15:51:55 -0800548 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832",
sfricke-samsungabab4632020-05-04 06:51:46 -0700549 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
550 "is not VK_TRUE.",
551 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
552 }
553 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
554 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
555 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800556 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833",
sfricke-samsungabab4632020-05-04 06:51:46 -0700557 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
558 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
559 }
560 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
561 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
562 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800563 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834",
sfricke-samsungabab4632020-05-04 06:51:46 -0700564 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
565 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
566 }
567 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
568 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
569 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
570 skip |=
Mike Schuchardt9969d022021-12-20 15:51:55 -0800571 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835",
sfricke-samsungabab4632020-05-04 06:51:46 -0700572 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
573 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
574 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
575 }
576 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200577 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
578 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
579 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
580 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
581 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
582 }
583 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700584 }
585
Tony-LunarG273f32f2021-09-28 08:56:30 -0600586 const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(pCreateInfo->pNext);
587 if (vulkan_13_features) {
588 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
589 while (current) {
590 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES ||
591 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES ||
592 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES ||
593 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES ||
594 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES ||
595 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES ||
596 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES ||
597 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES ||
598 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES ||
599 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES ||
600 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES ||
601 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES ||
602 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES) {
Nathaniel Cesario7a1f5b02022-06-06 12:32:59 -0600603 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-06532",
604 "vkCreateDevice(): %s structure included in VkPhysicalDeviceVulkan13Features' pNext chain.",
605 string_VkStructureType(current->sType));
Tony-LunarG273f32f2021-09-28 08:56:30 -0600606 break;
607 }
608 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
609 }
610 }
611
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600612 // Validate pCreateInfo->pQueueCreateInfos
613 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614
615 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700616 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
617 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600618 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700619 skip |=
620 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
621 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
622 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
623 "index value.",
624 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600625 }
626
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700627 if (queue_create_info.pQueuePriorities != nullptr) {
628 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
629 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600630 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
632 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
633 "] (=%f) is not between 0 and 1 (inclusive).",
634 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600635 }
636 }
637 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700638
639 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700640 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700641 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700642 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700643 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700644 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700645 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700646 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700647 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800648 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700649 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800650 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
651 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700652 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600653 }
654 }
655
sfricke-samsung30a57412020-05-15 21:14:54 -0700656 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700657 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700658 VkBool32 variable_pointers = VK_FALSE;
659 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700660 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700661 variable_pointers = vulkan_11_features->variablePointers;
662 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700663 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700664 variable_pointers = variable_pointers_features->variablePointers;
665 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700666 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700667 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700668 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
669 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
670 }
671
sfricke-samsungfd76c342020-05-29 23:13:43 -0700672 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700673 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700674 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700675 VkBool32 multiview_geometry_shader = VK_FALSE;
676 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700677 if (vulkan_11_features) {
678 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700679 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
680 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700681 } else if (multiview_features) {
682 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700683 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
684 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700685 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700686 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700687 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
688 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
689 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700690 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700691 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
692 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
693 }
694
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600695 return skip;
696}
697
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500698bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700699 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700700 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
701 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
702 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 }
704
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700705 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600706}
707
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700708bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500709 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100710 bool skip = false;
711
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600712 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700713 skip |=
714 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600715
716 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
717 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
718 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
719 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700720 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
721 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
722 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600723 }
724
725 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
726 // queueFamilyIndexCount uint32_t values
727 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
729 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
730 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
731 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600732 }
733 }
734
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700735 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
736 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
737 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
738 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
739 }
740
741 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
742 skip |=
743 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
744 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
745 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
746 }
747
748 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
749 skip |=
750 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
751 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
752 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
753 }
754
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600755 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
756 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
757 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
758 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700759 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
760 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
761 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600762 }
Piers Daniella7f93b62021-11-20 12:32:04 -0700763
764 const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext);
765 if (maintenance4_features && maintenance4_features->maintenance4) {
766 if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) {
767 skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409",
768 "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size "
769 "VkPhysicalDeviceMaintenance4Properties.maxBufferSize");
770 }
771 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600772 }
773
774 return skip;
775}
776
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700777bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500778 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600779 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600780
781 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800782 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700783 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600784 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
785 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
786 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
787 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700788 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
789 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
790 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600791 }
792
793 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
794 // queueFamilyIndexCount uint32_t values
795 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700796 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
797 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
798 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
799 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600800 }
801 }
802
Dave Houlton413a6782018-05-22 13:01:54 -0600803 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700804 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600805 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600807 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700808 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600809
Dave Houlton413a6782018-05-22 13:01:54 -0600810 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700811 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600812 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700813 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600814
Dave Houlton130c0212018-01-29 13:39:56 -0700815 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700816 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
817 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700818 skip |= LogError(
819 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600820 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
821 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700822 }
823
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600824 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100825 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
826 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700827 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
828 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
829 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600830 }
831
832 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700833 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100834 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700835 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
836 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
837 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
838 ") are not equal.",
839 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100840 }
841
842 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700843 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
844 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
845 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
846 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100847 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600848 }
849
850 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 skip |= LogError(
852 device, "VUID-VkImageCreateInfo-imageType-00957",
853 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600854 }
855 }
856
Dave Houlton130c0212018-01-29 13:39:56 -0700857 // 3D image may have only 1 layer
858 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
860 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700861 }
862
Dave Houlton130c0212018-01-29 13:39:56 -0700863 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
864 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
865 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
866 // At least one of the legal attachment bits must be set
867 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
869 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700870 }
871 // No flags other than the legal attachment bits may be set
872 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
873 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700874 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
875 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700876 }
877 }
878
Jeff Bolzef40fec2018-09-01 22:04:34 -0500879 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700880 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500881 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700882 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700883 ? static_cast<uint32_t>(ceil(log2(max_dim)))
884 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
885 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600886 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700887 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
888 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
889 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600890 }
891
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700892 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700893 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
894 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
895 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600896 }
897
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700898 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
900 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
901 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100902 }
903
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700904 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700905 skip |= LogError(
906 device, "VUID-VkImageCreateInfo-flags-01924",
907 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
908 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
909 }
910
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600911 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
912 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700913 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
914 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700915 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
916 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
917 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600918 }
919
920 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700921 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600922 // Linear tiling is unsupported
923 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700924 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700925 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
926 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600927 }
928
929 // Sparse 1D image isn't valid
930 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
932 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600933 }
934
935 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700936 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
938 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
939 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600940 }
941
942 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700943 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700944 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
945 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
946 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600947 }
948
949 // Multi-sample 2D image when device doesn't support it
950 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700951 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600952 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700953 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
954 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
955 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700956 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600957 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700958 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
959 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
960 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700961 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600962 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700963 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
964 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
965 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700966 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600967 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700968 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
969 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
970 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600971 }
972 }
973 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500974
Jeff Bolz9af91c52018-09-01 21:53:57 -0500975 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
976 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700977 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
978 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
979 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500980 }
981 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700982 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
983 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
984 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500985 }
986 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700987 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
988 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
989 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500990 }
991 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500992
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700993 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600994 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700995 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
996 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
997 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500998 }
999
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001000 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001001 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
1002 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -08001003 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
1004 "depth/stencil format.",
1005 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -05001006 }
1007
Dave Houlton142c4cb2018-10-17 15:04:41 -06001008 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001009 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
1010 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
1011 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
1012 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001013 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001014 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001015 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
1016 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
1017 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
1018 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -05001019 }
1020 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05001021
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001022 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -08001023 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -07001024 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
1025 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -08001026 "format (%s) must be a depth or depth/stencil format.",
1027 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -07001028 }
1029
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001030 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001031 if (image_stencil_struct != nullptr) {
1032 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
1033 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
1034 // No flags other than the legal attachment bits may be set
1035 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
1036 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001037 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
1038 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
1039 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
1040 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001041 }
1042 }
1043
sfricke-samsung61a57c02021-01-10 21:35:12 -08001044 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -05001045 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
1046 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001047 skip |=
1048 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
1049 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1050 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
1051 ") exceeds device "
1052 "maxFramebufferWidth (%" PRIu32 ")",
1053 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001054 }
1055
1056 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001057 skip |=
1058 LogError(device, "VUID-VkImageCreateInfo-format-02537",
1059 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1060 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
1061 ") exceeds device "
1062 "maxFramebufferHeight (%" PRIu32 ")",
1063 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001064 }
1065 }
1066
1067 if (!physical_device_features.shaderStorageImageMultisample &&
1068 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1069 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1070 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001071 LogError(device, "VUID-VkImageCreateInfo-format-02538",
1072 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1073 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
1074 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001075 }
1076
1077 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1078 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001079 skip |= LogError(
1080 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001081 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1082 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1083 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1084 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1085 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001086 skip |= LogError(
1087 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001088 "vkCreateImage(): Depth-stencil image in which usage does not include "
1089 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1090 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1091 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1092 }
1093
1094 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1095 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001096 skip |= LogError(
1097 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001098 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1099 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1100 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1101 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1102 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001103 skip |= LogError(
1104 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001105 "vkCreateImage(): Depth-stencil image in which usage does not include "
1106 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1107 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1108 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1109 }
1110 }
1111 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001112
1113 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1114 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1115 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1116 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1117 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1118 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001119
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001120 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001121 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001122 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1123 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001124 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1125 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1126 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1127 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1128 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1129 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1130 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001131 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001132 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1133 } else if (drm_format_mod_list != nullptr) {
1134 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1135 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1136 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001137 }
1138 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1139 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1140 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1141 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1142 "in the pNext chain");
1143 }
1144 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001145
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001146 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001147 bool image_create_maybe_linear = false;
1148 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1149 image_create_maybe_linear = true;
1150 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1151 image_create_maybe_linear = false;
1152 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1153 image_create_maybe_linear =
1154 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001155 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001156 }
1157
1158 // If multi-sample, validate type, usage, tiling and mip levels.
1159 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001160 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001161 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1162 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1163 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1164 }
1165
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001166 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001167 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1168 image_create_maybe_linear)) {
1169 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1170 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1171 }
1172
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001173 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1174 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1175 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1176 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1177 "imageType must be VK_IMAGE_TYPE_2D.");
1178 }
1179 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1180 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1181 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1182 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1183 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001184 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001185 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001186 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1187 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1188 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1189 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1190 }
1191 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1192 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1193 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1194 "imageType must be VK_IMAGE_TYPE_2D.");
1195 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001196 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001197 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1198 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1199 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1200 }
1201 if (pCreateInfo->mipLevels != 1) {
1202 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001203 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1204 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001205 pCreateInfo->mipLevels);
1206 }
1207 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001208
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001209 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001210 if (swapchain_create_info != nullptr) {
1211 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1212 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1213 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1214 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1215 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1216 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1217
1218 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1219 // also implicitly forces the check above that extent.depth is 1
1220 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1221 string_VkImageType(pCreateInfo->imageType));
1222 }
1223 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001224 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001225 pCreateInfo->mipLevels);
1226 }
1227 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1228 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1229 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1230 }
1231 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1232 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1233 base_message, string_VkImageTiling(pCreateInfo->tiling));
1234 }
1235 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1236 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1237 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1238 }
1239 const VkImageCreateFlags valid_flags =
1240 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001241 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001242 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001243 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001244 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001245 }
1246 }
1247 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001248
1249 // If Chroma subsampled format ( _420_ or _422_ )
1250 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1251 skip |=
1252 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1253 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1254 ") must be a multiple of 2.",
1255 string_VkFormat(image_format), pCreateInfo->extent.width);
1256 }
1257 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1258 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1259 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1260 ") must be a multiple of 2.",
1261 string_VkFormat(image_format), pCreateInfo->extent.height);
1262 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001263
1264 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1265 if (format_list_info) {
1266 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1267 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1268 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1269 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001270 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001271 viewFormatCount);
1272 }
1273 // Check if viewFormatCount is not zero that it is all compatible
1274 for (uint32_t i = 0; i < viewFormatCount; i++) {
Mike Schuchardtb0608492022-04-05 18:52:48 -07001275 const bool class_compatible =
1276 FormatCompatibilityClass(format_list_info->pViewFormats[i]) == FormatCompatibilityClass(image_format);
1277 if (!class_compatible) {
1278 if (image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) {
1279 const bool size_compatible =
1280 FormatIsCompressed(format_list_info->pViewFormats[i])
1281 ? false
1282 : FormatElementSize(format_list_info->pViewFormats[i]) == FormatElementSize(image_format);
1283 if (!size_compatible) {
1284 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1285 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1286 "] (%s) and VkImageCreateInfo::format (%s) are not compatible or size-compatible.",
1287 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1288 }
1289 } else {
1290 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1291 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1292 "] (%s) and VkImageCreateInfo::format (%s) are not compatible.",
1293 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1294 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001295 }
1296 }
1297 }
Younggwan Kimff6495a2021-12-16 20:28:45 +00001298
1299 const auto image_compression_control = LvlFindInChain<VkImageCompressionControlEXT>(pCreateInfo->pNext);
1300 if (image_compression_control) {
1301 constexpr VkImageCompressionFlagsEXT AllVkImageCompressionFlagBitsEXT =
1302 (VK_IMAGE_COMPRESSION_DEFAULT_EXT | VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT |
1303 VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT | VK_IMAGE_COMPRESSION_DISABLED_EXT);
1304 skip |= validate_flags("vkCreateImage", "VkImageCompressionControlEXT::flags", "VkImageCompressionFlagsEXT",
1305 AllVkImageCompressionFlagBitsEXT, image_compression_control->flags, kRequiredSingleBit,
1306 "VUID-VkImageCompressionControlEXT-flags-06747");
1307
1308 if (image_compression_control->flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT &&
1309 !image_compression_control->pFixedRateFlags) {
1310 skip |= LogError(
1311 device, "VUID-VkImageCompressionControlEXT-flags-06748",
1312 "VkImageCompressionControlEXT::pFixedRateFlags is nullptr even though VkImageCompressionControlEXT::flags are %s",
1313 string_VkImageCompressionFlagsEXT(image_compression_control->flags).c_str());
1314 }
1315 }
Tony-LunarG115f89d2022-06-15 10:53:22 -06001316#ifdef VK_USE_PLATFORM_METAL_EXT
1317 auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pCreateInfo->pNext);
1318 while (export_metal_object_info) {
1319 if ((export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT) &&
1320 (export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT)) {
1321 skip |=
1322 LogError(device, "VUID-VkImageCreateInfo-pNext-06783",
1323 "vkCreateImage(): The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose "
1324 "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of "
1325 "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT or VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT are allowed",
1326 string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType));
1327 }
1328 export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext);
1329 }
1330 auto import_metal_texture_info = LvlFindInChain<VkImportMetalTextureInfoEXT>(pCreateInfo->pNext);
1331 while (import_metal_texture_info) {
1332 if ((import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_0_BIT) &&
1333 (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_1_BIT) &&
1334 (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_2_BIT)) {
1335 skip |=
1336 LogError(device, "VUID-VkImageCreateInfo-pNext-06784",
1337 "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose "
1338 "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",
1339 string_VkImageAspectFlags(import_metal_texture_info->plane).c_str());
1340 }
1341 auto format_plane_count = FormatPlaneCount(pCreateInfo->format);
1342 if ((format_plane_count <= 1) && (import_metal_texture_info->plane != VK_IMAGE_ASPECT_PLANE_0_BIT)) {
1343 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06785",
1344 "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose "
1345 "plane = %s, but only VK_IMAGE_ASPECT_PLANE_0_BIT is allowed for an image created with format %s, which is not multiplaner",
1346 string_VkImageAspectFlags(import_metal_texture_info->plane).c_str(),
1347 string_VkFormat(pCreateInfo->format));
1348 }
1349 if ((format_plane_count == 2) && (import_metal_texture_info->plane == VK_IMAGE_ASPECT_PLANE_2_BIT)) {
1350 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06786",
1351 "vkCreateImage(): The pNext chain contains a VkImportMetalTextureInfoEXT whose "
1352 "plane == VK_IMAGE_ASPECT_PLANE_2_BIT, which is not allowed for an image created with format %s, "
1353 "which has only 2 planes",
1354 string_VkFormat(pCreateInfo->format));
1355 }
1356 import_metal_texture_info = LvlFindInChain<VkImportMetalTextureInfoEXT>(import_metal_texture_info->pNext);
1357 }
1358#endif // VK_USE_PLATFORM_METAL_EXT
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001359 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001360
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001361 return skip;
1362}
1363
Jeff Bolz99e3f632020-03-24 22:59:22 -05001364bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1365 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1366 bool skip = false;
1367
1368 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001369 // Validate feature set if using CUBE_ARRAY
1370 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1371 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1372 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1373 "enabling the imageCubeArray feature.");
1374 }
1375
Jeff Bolz99e3f632020-03-24 22:59:22 -05001376 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1377 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1378 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001379 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1380 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001381 pCreateInfo->subresourceRange.layerCount);
1382 }
1383 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001384 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1385 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1386 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1387 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001388 }
1389 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001390
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001391 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001392 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001393 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1394 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1395 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1396 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1397 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1398 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1399 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001400 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1401 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001402 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1403 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1404 "not an ASTC format.",
1405 string_VkFormat(pCreateInfo->format));
1406 }
1407 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001408
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001409 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001410 if (ycbcr_conversion != nullptr) {
1411 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1412 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1413 skip |= LogError(
1414 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1415 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1416 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1417 "r swizzle = %s\n"
1418 "g swizzle = %s\n"
1419 "b swizzle = %s\n"
1420 "a swizzle = %s\n",
1421 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1422 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1423 }
1424 }
1425 }
Tony-LunarG115f89d2022-06-15 10:53:22 -06001426#ifdef VK_USE_PLATFORM_METAL_EXT
1427 skip |= ExportMetalObjectsPNextUtil(
1428 VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkImageViewCreateInfo-pNext-06787",
1429 "vkCreateImageView():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pCreateInfo->pNext);
1430#endif // VK_USE_PLATFORM_METAL_EXT
Jeff Bolz99e3f632020-03-24 22:59:22 -05001431 }
1432 return skip;
1433}
1434
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001435bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001436 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001437 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001438
1439 // Note: for numerical correctness
1440 // - float comparisons should expect NaN (comparison always false).
1441 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1442
1443 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001444 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001445 if (v1_f <= 0.0f) return true;
1446
1447 float intpart;
1448 const float fract = modff(v1_f, &intpart);
1449
1450 assert(std::numeric_limits<float>::radix == 2);
1451 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1452 if (intpart >= u32_max_plus1) return false;
1453
1454 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001455 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001456 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001457 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001458 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001459 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001460 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001461 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001462 };
1463
1464 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1465 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1466 return (v1_f <= v2_f);
1467 };
1468
1469 // width
1470 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001471 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001472
1473 if (!(viewport.width > 0.0f)) {
1474 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001475 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1476 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001477 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1478 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |= LogError(object, "VUID-VkViewport-width-01771",
1480 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1481 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001482 }
1483
1484 // height
1485 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001486 const bool negative_height_enabled =
1487 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001488 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001489
1490 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1491 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001492 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1493 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001494 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1495 height_healthy = false;
1496
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001497 skip |= LogError(object, "VUID-VkViewport-height-01773",
1498 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1499 ").",
1500 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001501 }
1502
1503 // x
1504 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001505 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001506 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001507 skip |= LogError(object, "VUID-VkViewport-x-01774",
1508 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1509 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001510 }
1511
1512 // x + width
1513 if (x_healthy && width_healthy) {
1514 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001515 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001516 skip |= LogError(
1517 object, "VUID-VkViewport-x-01232",
1518 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1519 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1520 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001521 }
1522 }
1523
1524 // y
1525 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001526 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001527 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001528 skip |= LogError(object, "VUID-VkViewport-y-01775",
1529 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1530 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001531 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001532 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001533 skip |= LogError(object, "VUID-VkViewport-y-01776",
1534 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1535 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001536 }
1537
1538 // y + height
1539 if (y_healthy && height_healthy) {
1540 const float boundary = viewport.y + viewport.height;
1541
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001542 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001543 skip |= LogError(object, "VUID-VkViewport-y-01233",
1544 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1545 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1546 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001547 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001548 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001549 LogError(object, "VUID-VkViewport-y-01777",
1550 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1551 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1552 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001553 }
1554 }
1555
sfricke-samsungfd06d422021-01-22 02:17:21 -08001556 // 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 -07001557 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001558 // minDepth
1559 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001560 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001561 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001562 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1563 "[0.0, 1.0] range.",
1564 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001565 }
1566
1567 // maxDepth
1568 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001569 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001570 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001571 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1572 "[0.0, 1.0] range.",
1573 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001574 }
1575 }
1576
1577 return skip;
1578}
1579
Dave Houlton142c4cb2018-10-17 15:04:41 -06001580struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001581 VkShadingRatePaletteEntryNV shadingRate;
1582 uint32_t width;
1583 uint32_t height;
1584};
1585
1586// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001587static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001588 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1589 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1590 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1591 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1592 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1593 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001594};
1595
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001596bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001597 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001598
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001599 SampleOrderInfo *sample_order_info;
1600 uint32_t info_idx = 0;
1601 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1602 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1603 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001604 break;
1605 }
1606 }
1607
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001608 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001609 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1610 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1611 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001612 return skip;
1613 }
1614
Dave Houlton142c4cb2018-10-17 15:04:41 -06001615 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001616 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001617 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1618 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1619 ") must "
1620 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1621 "is set in framebufferNoAttachmentsSampleCounts.",
1622 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001623 }
1624
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001625 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001626 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1627 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1628 ") must "
1629 "be equal to the product of sampleCount (=%" PRIu32
1630 "), the fragment width for shadingRate "
1631 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001632 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001633 }
1634
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001635 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001636 skip |= LogError(
1637 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001638 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1639 ") must "
1640 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001641 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001642 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001643
1644 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001645 // the first width*height*sampleCount bits to all be set. Note: There is no
1646 // guarantee that 64 bits is enough, but practically it's unlikely for an
1647 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001648 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001649 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001650 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001651 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1652 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001653 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1654 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001655 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001656 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001657 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1658 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001659 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001660 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001661 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1662 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001663 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001664 uint32_t idx =
1665 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1666 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001667 }
1668
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001669 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1670 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001671 skip |= LogError(
1672 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001673 "The array pSampleLocations must contain exactly one entry for "
1674 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001675 }
1676
1677 return skip;
1678}
1679
sfricke-samsung51303fb2021-05-09 19:09:13 -07001680bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1681 const VkAllocationCallbacks *pAllocator,
1682 VkPipelineLayout *pPipelineLayout) const {
1683 bool skip = false;
1684 // Validate layout count against device physical limit
1685 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1686 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001687 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1688 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001689 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1690 }
1691
Nathaniel Cesario73c994c2022-05-26 23:07:34 -06001692 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001693 for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
1694 if (!pCreateInfo->pSetLayouts[i]) {
Nathaniel Cesario73c994c2022-05-26 23:07:34 -06001695 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561",
1696 "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32
1697 "] is VK_NULL_HANDLE, but VK_EXT_graphics_pipeline_library is not enabled.",
1698 i);
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001699 }
1700 }
1701 }
1702
sfricke-samsung51303fb2021-05-09 19:09:13 -07001703 // Validate Push Constant ranges
1704 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1705 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1706 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1707 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1708 // Check that offset + size don't exceed the max.
1709 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1710 if (offset >= max_push_constants_size) {
1711 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001712 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1713 ") that exceeds this "
1714 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001715 i, offset, max_push_constants_size);
1716 }
1717 if (size > max_push_constants_size - offset) {
1718 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001719 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1720 ") and size (%" PRIu32
1721 ") "
1722 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001723 i, offset, size, max_push_constants_size);
1724 }
1725
1726 // size needs to be non-zero and a multiple of 4.
1727 if (size == 0) {
1728 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001729 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1730 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001731 i, size);
1732 }
1733 if (size & 0x3) {
1734 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001735 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1736 ") is not a multiple of 4.",
1737 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001738 }
1739
1740 // offset needs to be a multiple of 4.
1741 if ((offset & 0x3) != 0) {
1742 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001743 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1744 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001745 i, offset);
1746 }
1747 }
1748
1749 // 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.
1750 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1751 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1752 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001753 skip |=
1754 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1755 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001756 }
1757 }
1758 }
1759 return skip;
1760}
1761
ziga-lunargc6341372021-07-28 12:57:42 +02001762bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1763 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1764 bool skip = false;
1765
1766 const auto *required_subgroup_size_features =
1767 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1768
1769 if (required_subgroup_size_features) {
1770 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1771 skip |= LogError(
1772 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1773 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1774 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1775 func_name, msg, pCreateInfo->flags);
1776 }
1777 }
1778
1779 return skip;
1780}
1781
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001782bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1783 uint32_t createInfoCount,
1784 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1785 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001786 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001787 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001788
1789 if (pCreateInfos != nullptr) {
1790 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001791 bool has_dynamic_viewport = false;
1792 bool has_dynamic_scissor = false;
1793 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001794 bool has_dynamic_depth_bias = false;
1795 bool has_dynamic_blend_constant = false;
1796 bool has_dynamic_depth_bounds = false;
1797 bool has_dynamic_stencil_compare = false;
1798 bool has_dynamic_stencil_write = false;
1799 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001800 bool has_dynamic_viewport_w_scaling_nv = false;
1801 bool has_dynamic_discard_rectangle_ext = false;
1802 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001803 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001804 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001805 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001806 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001807 bool has_dynamic_cull_mode = false;
1808 bool has_dynamic_front_face = false;
1809 bool has_dynamic_primitive_topology = false;
1810 bool has_dynamic_viewport_with_count = false;
1811 bool has_dynamic_scissor_with_count = false;
1812 bool has_dynamic_vertex_input_binding_stride = false;
1813 bool has_dynamic_depth_test_enable = false;
1814 bool has_dynamic_depth_write_enable = false;
1815 bool has_dynamic_depth_compare_op = false;
1816 bool has_dynamic_depth_bounds_test_enable = false;
1817 bool has_dynamic_stencil_test_enable = false;
1818 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001819 bool has_patch_control_points = false;
1820 bool has_rasterizer_discard_enable = false;
1821 bool has_depth_bias_enable = false;
1822 bool has_logic_op = false;
1823 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001824 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001825
1826 // Create a copy of create_info and set non-included sub-state to null
1827 auto create_info = pCreateInfos[i];
1828 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1829 if (graphics_lib_info) {
Nathaniel Cesariobcb79682022-03-31 21:13:52 -06001830 // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries
1831 if (enabled[gpu_validation]) {
1832 skip |=
1833 LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported");
1834 }
1835 if (enabled[gpu_validation]) {
1836 skip |= LogError(device, kVUIDUndefined,
1837 "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported");
1838 }
1839
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001840 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1841 create_info.pVertexInputState = nullptr;
1842 create_info.pInputAssemblyState = nullptr;
1843 }
1844 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1845 create_info.pViewportState = nullptr;
1846 create_info.pRasterizationState = nullptr;
1847 create_info.pTessellationState = nullptr;
1848 }
1849 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1850 create_info.pDepthStencilState = nullptr;
1851 }
1852 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1853 create_info.pColorBlendState = nullptr;
1854 }
1855 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1856 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1857 create_info.pMultisampleState = nullptr;
1858 }
1859 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1860 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1861 create_info.layout = VK_NULL_HANDLE;
1862 }
1863 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1864 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1865 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1866 create_info.renderPass = VK_NULL_HANDLE;
1867 create_info.subpass = 0;
1868 }
1869 }
1870
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001871 if (!create_info.renderPass) {
1872 if (create_info.pColorBlendState && create_info.pMultisampleState) {
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001873 const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext);
ziga-lunarg97584c32022-04-22 14:33:37 +02001874 // Pipeline has fragment output state
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001875 if (rendering_struct) {
1876 if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1877 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1878 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1879 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001880
1881 if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) {
1882 skip |= LogError(
1883 device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587",
1884 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1885 "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.",
1886 i, string_VkFormat(rendering_struct->depthAttachmentFormat));
1887 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001888 }
1889
1890 if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1891 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1892 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1893 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001894 if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) {
Nathaniel Cesario1ba7ca52022-04-18 12:35:00 -06001895 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588",
1896 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1897 "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a "
1898 "stencil aspect.",
1899 i, string_VkFormat(rendering_struct->stencilAttachmentFormat));
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001900 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001901 }
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001902
1903 if (rendering_struct->colorAttachmentCount != 0) {
1904 skip |= validate_ranged_enum_array(
1905 "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579",
1906 "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums,
1907 rendering_struct->colorAttachmentCount, rendering_struct->pColorAttachmentFormats, true, true);
1908 }
ziga-lunarg97584c32022-04-22 14:33:37 +02001909
1910 if (rendering_struct->pColorAttachmentFormats) {
1911 for (uint32_t j = 0; j < rendering_struct->colorAttachmentCount; ++j) {
1912 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "pColorAttachmentFormats", "VkFormat",
1913 AllVkFormatEnums, rendering_struct->pColorAttachmentFormats[j],
1914 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
1915 }
1916 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001917 }
ziga-lunarg47258542022-04-22 17:40:43 +02001918
1919 // VkAttachmentSampleCountInfoAMD == VkAttachmentSampleCountInfoNV
1920 auto attachment_sample_count_info = LvlFindInChain<VkAttachmentSampleCountInfoAMD>(create_info.pNext);
1921 if (attachment_sample_count_info && attachment_sample_count_info->pColorAttachmentSamples) {
1922 for (uint32_t j = 0; j < attachment_sample_count_info->colorAttachmentCount; ++j) {
1923 skip |= validate_flags("vkCreateGraphicsPipelines",
1924 ParameterName("VkAttachmentSampleCountInfoAMD->pColorAttachmentSamples"),
1925 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
1926 attachment_sample_count_info->pColorAttachmentSamples[j], kRequiredFlags,
1927 "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
1928 }
1929 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001930 }
1931 }
1932
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001933 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1934 if (create_info.stageCount == 0) {
1935 skip |=
1936 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1937 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1938 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1939 }
1940 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1941 // ParameterName::IndexFormatSpecifier
1942 skip |= validate_struct_type_array(
1943 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1944 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
1945 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages,
1946 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1947 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06001948 "VUID-VkGraphicsPipelineCreateInfo-pStages-06600");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001949 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1950 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1951 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
1952 pCreateInfos[i].pRasterizationState,
1953 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1954 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1955 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001956 }
1957
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001958 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1959 if (create_info.pDynamicState != nullptr) {
1960 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001961 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1962 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001963 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1964 if (has_dynamic_viewport == true) {
1965 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1966 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001967 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001968 i);
1969 }
1970 has_dynamic_viewport = true;
1971 }
1972 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1973 if (has_dynamic_scissor == true) {
1974 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1975 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001976 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001977 i);
1978 }
1979 has_dynamic_scissor = true;
1980 }
1981 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1982 if (has_dynamic_line_width == true) {
1983 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1984 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001985 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001986 i);
1987 }
1988 has_dynamic_line_width = true;
1989 }
1990 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1991 if (has_dynamic_depth_bias == true) {
1992 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1993 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001994 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001995 i);
1996 }
1997 has_dynamic_depth_bias = true;
1998 }
1999 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
2000 if (has_dynamic_blend_constant == true) {
2001 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2002 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002003 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002004 i);
2005 }
2006 has_dynamic_blend_constant = true;
2007 }
2008 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
2009 if (has_dynamic_depth_bounds == true) {
2010 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2011 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002012 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002013 i);
2014 }
2015 has_dynamic_depth_bounds = true;
2016 }
2017 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
2018 if (has_dynamic_stencil_compare == true) {
2019 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2020 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002021 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002022 i);
2023 }
2024 has_dynamic_stencil_compare = true;
2025 }
2026 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
2027 if (has_dynamic_stencil_write == true) {
2028 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2029 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002030 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002031 i);
2032 }
2033 has_dynamic_stencil_write = true;
2034 }
2035 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
2036 if (has_dynamic_stencil_reference == true) {
2037 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2038 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002039 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002040 i);
2041 }
2042 has_dynamic_stencil_reference = true;
2043 }
2044 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
2045 if (has_dynamic_viewport_w_scaling_nv == true) {
2046 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2047 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002048 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002049 i);
2050 }
2051 has_dynamic_viewport_w_scaling_nv = true;
2052 }
2053 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
2054 if (has_dynamic_discard_rectangle_ext == true) {
2055 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2056 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002057 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002058 i);
2059 }
2060 has_dynamic_discard_rectangle_ext = true;
2061 }
2062 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
2063 if (has_dynamic_sample_locations_ext == true) {
2064 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2065 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002066 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002067 i);
2068 }
2069 has_dynamic_sample_locations_ext = true;
2070 }
2071 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
2072 if (has_dynamic_exclusive_scissor_nv == true) {
2073 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2074 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002075 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002076 i);
2077 }
2078 has_dynamic_exclusive_scissor_nv = true;
2079 }
2080 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
2081 if (has_dynamic_shading_rate_palette_nv == true) {
2082 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2083 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002084 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002085 i);
2086 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06002087 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07002088 }
2089 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
2090 if (has_dynamic_viewport_course_sample_order_nv == true) {
2091 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2092 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002093 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002094 i);
2095 }
2096 has_dynamic_viewport_course_sample_order_nv = true;
2097 }
2098 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
2099 if (has_dynamic_line_stipple == true) {
2100 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2101 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002102 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002103 i);
2104 }
2105 has_dynamic_line_stipple = true;
2106 }
Piers Daniell39842ee2020-07-10 16:42:33 -06002107 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
2108 if (has_dynamic_cull_mode) {
2109 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2110 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002111 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002112 i);
2113 }
2114 has_dynamic_cull_mode = true;
2115 }
2116 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
2117 if (has_dynamic_front_face) {
2118 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2119 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002120 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002121 i);
2122 }
2123 has_dynamic_front_face = true;
2124 }
2125 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
2126 if (has_dynamic_primitive_topology) {
2127 skip |= LogError(
2128 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2129 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002130 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002131 i);
2132 }
2133 has_dynamic_primitive_topology = true;
2134 }
2135 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2136 if (has_dynamic_viewport_with_count) {
2137 skip |= LogError(
2138 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2139 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002140 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002141 i);
2142 }
2143 has_dynamic_viewport_with_count = true;
2144 }
2145 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2146 if (has_dynamic_scissor_with_count) {
2147 skip |= LogError(
2148 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2149 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002150 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002151 i);
2152 }
2153 has_dynamic_scissor_with_count = true;
2154 }
2155 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2156 if (has_dynamic_vertex_input_binding_stride) {
2157 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2158 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2159 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002160 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002161 i);
2162 }
2163 has_dynamic_vertex_input_binding_stride = true;
2164 }
2165 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2166 if (has_dynamic_depth_test_enable) {
2167 skip |= LogError(
2168 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2169 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002170 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002171 i);
2172 }
2173 has_dynamic_depth_test_enable = true;
2174 }
2175 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2176 if (has_dynamic_depth_write_enable) {
2177 skip |= LogError(
2178 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2179 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002180 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002181 i);
2182 }
2183 has_dynamic_depth_write_enable = true;
2184 }
2185 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2186 if (has_dynamic_depth_compare_op) {
2187 skip |=
2188 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2189 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002190 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002191 i);
2192 }
2193 has_dynamic_depth_compare_op = true;
2194 }
2195 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2196 if (has_dynamic_depth_bounds_test_enable) {
2197 skip |= LogError(
2198 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2199 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002200 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002201 i);
2202 }
2203 has_dynamic_depth_bounds_test_enable = true;
2204 }
2205 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2206 if (has_dynamic_stencil_test_enable) {
2207 skip |= LogError(
2208 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2209 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002210 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002211 i);
2212 }
2213 has_dynamic_stencil_test_enable = true;
2214 }
2215 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2216 if (has_dynamic_stencil_op) {
2217 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2218 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002219 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002220 i);
2221 }
2222 has_dynamic_stencil_op = true;
2223 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002224 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2225 // Not allowed for graphics pipelines
2226 skip |= LogError(
2227 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2228 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002229 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2230 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002231 i, state_index);
2232 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002233 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2234 if (has_patch_control_points) {
2235 skip |= LogError(
2236 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2237 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002238 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002239 i);
2240 }
2241 has_patch_control_points = true;
2242 }
2243 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2244 if (has_rasterizer_discard_enable) {
2245 skip |= LogError(
2246 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2247 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002248 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002249 i);
2250 }
2251 has_rasterizer_discard_enable = true;
2252 }
2253 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2254 if (has_depth_bias_enable) {
2255 skip |= LogError(
2256 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2257 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002258 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002259 i);
2260 }
2261 has_depth_bias_enable = true;
2262 }
2263 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2264 if (has_logic_op) {
2265 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2266 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002267 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002268 i);
2269 }
2270 has_logic_op = true;
2271 }
2272 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2273 if (has_primitive_restart_enable) {
2274 skip |= LogError(
2275 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2276 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002277 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002278 i);
2279 }
2280 has_primitive_restart_enable = true;
2281 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002282 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2283 if (has_dynamic_vertex_input) {
2284 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002285 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2286 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2287 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002288 }
2289 has_dynamic_vertex_input = true;
2290 }
Petr Kraus299ba622017-11-24 03:09:03 +01002291 }
2292 }
2293
sfricke-samsung3b944422021-01-23 02:15:19 -08002294 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2295 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2296 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002297 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2298 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002299 i);
2300 }
2301
2302 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2303 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2304 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002305 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002306 i);
2307 }
2308
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002309 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2310 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002311 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002312 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2313 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2314 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002315 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002316 }
2317
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002319
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002320 // Collect active stages and other information
2321 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002322 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002323 bool has_eval = false;
2324 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002325 if (create_info.pStages != nullptr) {
2326 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2327 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002328
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002329 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002330 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002331 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002332 has_eval = true;
2333 }
2334
Tony-LunarGd29cc032022-05-13 14:38:27 -06002335 skip |= validate_required_pointer(
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002336 "vkCreateGraphicsPipelines",
Tony-LunarGd29cc032022-05-13 14:38:27 -06002337 ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}),
2338 create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter");
2339
2340 if (create_info.pStages[stage_index].pName) {
2341 skip |= validate_string(
2342 "vkCreateGraphicsPipelines",
2343 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2344 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
2345 }
ziga-lunargc6341372021-07-28 12:57:42 +02002346
2347 std::stringstream msg;
2348 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2349 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002350 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002351 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002352 }
2353
2354 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002355 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2356 skip |=
2357 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2358 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2359 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2360 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002361
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002362 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002363 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2364
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002365 skip |= validate_struct_pnext(
2366 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002367 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002368 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2369 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2370 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2371 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002372
2373 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002374 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002375 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2376 }
2377
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002378 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002379 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2380 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002381 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002382 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2383 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2384
2385 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002386 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002387 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002388
2389 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002390 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002391 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2392
2393 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2394 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002395 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002396 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2397
2398 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002399 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002400 }
2401
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002402 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2403 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002404
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002405 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002406 skip |=
2407 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2408 "vkCreateGraphicsPipelines: pararameter "
2409 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2410 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002411 }
2412
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002413 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002414 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002415 skip |=
2416 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2417 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2418 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2419 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2420 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002421 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2422 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002423 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002424 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2425 skip |=
2426 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2427 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002428 create_info.pVertexInputState->vertexBindingDescriptionCount,
2429 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002430 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2431
2432 skip |= validate_array(
2433 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2434 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2435 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2436 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2437
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002438 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002439 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002440 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002441 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002442 skip |= validate_ranged_enum(
2443 "vkCreateGraphicsPipelines",
2444 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2445 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002446 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002447 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2448 }
2449 }
2450
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002451 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002452 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002453 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002454 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002455 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002456 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002457 skip |= validate_ranged_enum(
2458 "vkCreateGraphicsPipelines",
2459 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2460 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002461 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002462 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002463 if (FormatIsDepthOrStencil(format)) {
2464 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2465 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2466 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2467 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002468 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2469 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002470 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2471 "alignment, replace with a color format.",
2472 i, vertex_attribute_description_index, string_VkFormat(format));
2473 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002474 }
2475 }
2476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002477 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002478 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2479 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002480 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2481 ") is "
2482 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002483 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002484 }
2485
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002486 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002487 skip |=
2488 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2489 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002490 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2491 ") is "
2492 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002493 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002494 }
2495
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002496 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2498 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002499 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2500 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002501 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2502 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002503 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2504 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002505 "(%" PRIu32 ") is not distinct.",
2506 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002507 }
2508 vertex_bindings.insert(vertex_bind_desc.binding);
2509
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002510 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002511 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2512 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002513 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2514 "].binding (%" PRIu32
2515 ") is "
2516 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002517 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002518 }
2519
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002520 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002521 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2522 "vkCreateGraphicsPipelines: parameter "
2523 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2524 "].stride (%" PRIu32
2525 ") is greater "
2526 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2527 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002528 }
2529 }
2530
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002531 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002532 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2533 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002534 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2535 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002536 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2537 "vkCreateGraphicsPipelines: parameter "
2538 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2539 "].location (%" PRIu32 ") is not distinct.",
2540 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002541 }
2542 attribute_locations.insert(vertex_attrib_desc.location);
2543
2544 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2545 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002546 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2547 "vkCreateGraphicsPipelines: parameter "
2548 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2549 "].binding (%" PRIu32
2550 ") does not exist "
2551 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2552 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002553 }
2554
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002555 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002556 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2557 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002558 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2559 "].location (%" PRIu32
2560 ") is "
2561 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002563 }
2564
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002565 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002566 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2567 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002568 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2569 "].binding (%" PRIu32
2570 ") is "
2571 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002572 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573 }
2574
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002575 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002576 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2577 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002578 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2579 "].offset (%" PRIu32
2580 ") is "
2581 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002582 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583 }
2584 }
2585 }
2586
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002587 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2588 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002589 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002590 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002591 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2592 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002593 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002594 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002595 i, i);
2596 } else {
2597 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2598 skip |= validate_struct_pnext(
2599 "vkCreateGraphicsPipelines",
2600 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002601 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002602 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2603 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002604
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002605 skip |= validate_reserved_flags(
2606 "vkCreateGraphicsPipelines",
2607 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002608 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002609
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002610 if (create_info.pTessellationState->patchControlPoints == 0 ||
2611 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2612 skip |=
2613 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2614 "vkCreateGraphicsPipelines: invalid parameter "
2615 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2616 ". patchControlPoints "
2617 "should be >0 and <=%" PRIu32 ".",
2618 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002619 }
2620 }
2621 }
2622
2623 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002624 if ((create_info.pRasterizationState != nullptr) &&
2625 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2626 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002627 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2628 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2629 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2630 "].pViewportState (=NULL) is not a valid pointer.",
2631 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002633 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002634
2635 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002636 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2637 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2638 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2639 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002640 }
2641
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002642 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002643 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002644 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2645 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002646 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2647 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002648 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002649 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002651 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002652 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002653 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002654 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002655 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002656 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002657 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002658 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002659 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002660
2661 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002662 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002663 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002664 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002665
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002666 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002667 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002668 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002669 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002670 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002671 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2672 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002673 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002674 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2675 const auto depth_clip_control_struct =
2676 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002677
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002678 if (!physical_device_features.multiViewport) {
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06002679 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount > 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002680 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2681 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2682 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2683 ") is not 1.",
2684 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002685 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002686
Nathaniel Cesario0d50bcf2022-06-21 10:30:04 -06002687 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount > 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002688 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2689 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2690 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2691 ") is not 1.",
2692 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002693 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002694
Dave Houlton142c4cb2018-10-17 15:04:41 -06002695 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2696 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002697 skip |= LogError(
2698 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2699 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2700 "disabled, but pCreateInfos[%" PRIu32
2701 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2702 ") is not 1.",
2703 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002704 }
2705
Jeff Bolz9af91c52018-09-01 21:53:57 -05002706 if (shading_rate_image_struct &&
2707 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002708 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2709 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2710 "disabled, but pCreateInfos[%" PRIu32
2711 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2712 ") is neither 0 nor 1.",
2713 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002714 }
2715
Petr Krausa6103552017-11-16 21:21:58 +01002716 } else { // multiViewport enabled
2717 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002718 if (!has_dynamic_viewport_with_count) {
2719 skip |= LogError(
2720 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2721 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2722 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002723 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002724 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2725 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2726 "].pViewportState->viewportCount (=%" PRIu32
2727 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2728 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002729 } else if (has_dynamic_viewport_with_count) {
2730 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2731 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2732 "].pViewportState->viewportCount (=%" PRIu32
2733 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2734 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002735 }
Petr Krausa6103552017-11-16 21:21:58 +01002736
2737 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002738 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002739 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2740 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2741 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002742 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002743 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002744 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2745 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002746 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002747 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2748 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2749 "].pViewportState->scissorCount (=%" PRIu32
2750 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2751 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002752 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002753 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2754 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2755 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2756 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002757 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2758 "].pViewportState->scissorCount (=%" PRIu32
2759 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2760 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002761 }
2762 }
2763
ziga-lunarg845883b2021-07-14 15:05:00 +02002764 if (!has_dynamic_scissor && viewport_state.pScissors) {
2765 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2766 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002767
2768 if (scissor.offset.x < 0) {
2769 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2770 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2771 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2772 scissor.offset.x, i, scissor_i);
2773 }
2774
2775 if (scissor.offset.y < 0) {
2776 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2777 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2778 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2779 scissor.offset.y, i, scissor_i);
2780 }
2781
ziga-lunarg845883b2021-07-14 15:05:00 +02002782 const int64_t x_sum =
2783 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2784 if (x_sum > std::numeric_limits<int32_t>::max()) {
2785 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2786 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2787 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2788 "] will overflow int32_t.",
2789 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2790 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002791
ziga-lunarg845883b2021-07-14 15:05:00 +02002792 const int64_t y_sum =
2793 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2794 if (y_sum > std::numeric_limits<int32_t>::max()) {
2795 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2796 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2797 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2798 "] will overflow int32_t.",
2799 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2800 }
2801 }
2802 }
2803
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002804 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002805 skip |=
2806 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2807 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2808 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2809 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002810 }
2811
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002812 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002813 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2814 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2815 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2816 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2817 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002818 }
2819
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002820 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2821 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2822 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2823 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2824 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2825 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2826 skip |= LogError(
2827 device, vuid,
2828 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2829 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2830 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2831 }
Petr Krausa6103552017-11-16 21:21:58 +01002832 }
2833
Dave Houlton142c4cb2018-10-17 15:04:41 -06002834 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002835 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002836 skip |=
2837 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2838 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2839 ") must be zero or identical to pCreateInfos[%" PRIu32
2840 "].pViewportState->viewportCount (=%" PRIu32 ").",
2841 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002842 }
2843
Dave Houlton142c4cb2018-10-17 15:04:41 -06002844 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002845 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002846 skip |= LogError(
2847 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002848 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2849 "] "
2850 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2851 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2852 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002853 }
2854
Petr Krausa6103552017-11-16 21:21:58 +01002855 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002856 skip |= LogError(
2857 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002858 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2859 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002860 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2861 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002862 }
2863
2864 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002865 skip |= LogError(
2866 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002867 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2868 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002869 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2870 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002871 }
2872
Jeff Bolz3e71f782018-08-29 23:15:45 -05002873 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002874 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2875 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2876 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002877 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002878 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2879 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2880 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2881 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002882 }
2883
Jeff Bolz9af91c52018-09-01 21:53:57 -05002884 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002885 shading_rate_image_struct->viewportCount > 0 &&
2886 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002887 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002888 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002889 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002890 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2891 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002892 i, i);
2893 }
2894
Chris Mayer328d8212018-12-11 14:16:18 +01002895 if (vp_swizzle_struct) {
2896 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002897 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2898 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2899 " does "
2900 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2901 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002902 }
2903 }
2904
Petr Krausb3fcdb42018-01-09 22:09:09 +01002905 // validate the VkViewports
2906 if (!has_dynamic_viewport && viewport_state.pViewports) {
2907 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2908 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002909 const char *fn_name = "vkCreateGraphicsPipelines";
2910 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2911 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2912 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002913 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002914 }
2915 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002916
sfricke-samsung45996a42021-09-16 13:45:27 -07002917 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002918 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2919 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2920 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2921 "VK_NV_clip_space_w_scaling extension is not enabled.",
2922 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002923 }
2924
sfricke-samsung45996a42021-09-16 13:45:27 -07002925 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002926 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2927 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2928 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2929 "VK_EXT_discard_rectangles extension is not enabled.",
2930 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002931 }
2932
sfricke-samsung45996a42021-09-16 13:45:27 -07002933 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002934 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2935 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2936 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2937 "VK_EXT_sample_locations extension is not enabled.",
2938 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002939 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002940
sfricke-samsung45996a42021-09-16 13:45:27 -07002941 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002942 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2943 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2944 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2945 "VK_NV_scissor_exclusive extension is not enabled.",
2946 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002947 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002948
2949 if (coarse_sample_order_struct &&
2950 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2951 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002952 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2953 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2954 "] "
2955 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2956 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2957 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002958 }
2959
2960 if (coarse_sample_order_struct) {
2961 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002962 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002963 }
2964 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002965
2966 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2967 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002968 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2969 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2970 "] "
2971 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2972 ") "
2973 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2974 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002975 }
2976 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002977 skip |= LogError(
2978 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002979 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2980 "] "
2981 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2982 i);
2983 }
2984 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002985
2986 if (depth_clip_control_struct) {
2987 const auto *depth_clip_control_features =
2988 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2989 const bool enabled_depth_clip_control =
2990 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2991 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2992 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2993 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2994 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2995 "depthClipControl feature is not enabled. ",
2996 i);
2997 }
2998 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002999 }
3000
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003001 const bool is_frag_out_graphics_lib =
3002 graphics_lib_info &&
3003 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003004 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003006 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
3007 "].pRasterizationState->rasterizerDiscardEnable "
3008 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003009 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003010 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07003011 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06003012 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07003013 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
3014 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07003015 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07003016 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07003017 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003018
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003019 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003020 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003021 skip |= validate_struct_pnext(
3022 "vkCreateGraphicsPipelines",
3023 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003024 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003025 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
3026 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003027
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003028 skip |= validate_reserved_flags(
3029 "vkCreateGraphicsPipelines",
3030 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003031 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003032
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003033 skip |= validate_bool32(
3034 "vkCreateGraphicsPipelines",
3035 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003036 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003038 skip |= validate_array(
3039 "vkCreateGraphicsPipelines",
3040 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
3041 ParameterName::IndexVector{i}),
3042 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003043 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
3044 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003045
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003046 skip |= validate_flags("vkCreateGraphicsPipelines",
3047 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
3048 ParameterName::IndexVector{i}),
3049 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003050 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003051 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003052
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003053 skip |= validate_bool32("vkCreateGraphicsPipelines",
3054 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
3055 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003056 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003057
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003058 skip |= validate_bool32(
3059 "vkCreateGraphicsPipelines",
3060 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003061 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003062
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003063 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003064 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
3065 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3066 "].pMultisampleState->sType must be "
3067 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003068 i);
John Zulauf7acac592017-11-06 11:15:53 -07003069 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003070 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003071 if (!physical_device_features.sampleRateShading) {
3072 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
3073 "vkCreateGraphicsPipelines(): parameter "
3074 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
3075 i);
3076 }
3077 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
3078 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003079 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003080 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003081
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003082 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
3083 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
3084 "].pMultisampleState->minSampleShading.",
3085 i);
3086 }
John Zulauf7acac592017-11-06 11:15:53 -07003087 }
3088 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003089
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003090 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003091 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003092
3093 if (line_state) {
3094 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
3095 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003096 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003097 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003098 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3099 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003100 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003101 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003102 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003103 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003104 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003105 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3106 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003107 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003108 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003109 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003110 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003111 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003112 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3113 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003114 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003115 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003116 }
3117 }
3118 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3119 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3120 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003121 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003122 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3123 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003124 "range [1,256].",
3125 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003126 }
3127 }
3128 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003129 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003130 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3131 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003132 skip |=
3133 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003134 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3135 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3137 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003138 }
3139 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3140 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003141 skip |=
3142 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003143 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3144 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003145 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3146 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003147 }
3148 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3149 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003150 skip |=
3151 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003152 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3153 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003154 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3155 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003156 }
3157 if (line_state->stippledLineEnable) {
3158 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3159 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003160 skip |=
3161 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003162 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3163 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003164 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3165 "stippledRectangularLines feature.",
3166 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003167 }
3168 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3169 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003170 skip |=
3171 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003172 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3173 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003174 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3175 "stippledBresenhamLines feature.",
3176 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003177 }
3178 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3179 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003180 skip |=
3181 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003182 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3183 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003184 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3185 "stippledSmoothLines feature.",
3186 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003187 }
3188 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003189 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003190 skip |=
3191 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003192 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3193 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003194 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3195 "stippledRectangularLines and strictLines features.",
3196 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003197 }
3198 }
3199 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003200 }
3201
Petr Krause91f7a12017-12-14 20:57:36 +01003202 bool uses_color_attachment = false;
3203 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003204 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003205 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003206 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003207 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003208 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003209 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003210 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003211 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003212 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003213 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003214 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003215 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003216 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003217 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003218 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003219 }
3220
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003221 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003222 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003223 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003225 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003226 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003227
Mike Schuchardt00e81452021-11-29 11:11:20 -08003228 skip |=
3229 validate_flags("vkCreateGraphicsPipelines",
3230 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3231 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003232 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003233 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003234
3235 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003236 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003237 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003238 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239
3240 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003241 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003243 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003244
3245 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003246 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003247 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003248 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003249 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003250
3251 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003252 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003253 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003254 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003255
3256 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003257 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003258 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003259 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003260
3261 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003262 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003263 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003264 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003265 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003266
3267 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003268 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003269 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003270 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003271 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003272
3273 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003274 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003275 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003276 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003277 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003278
3279 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003280 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003281 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003282 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003283 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003284
3285 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003286 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003287 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003288 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003289 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003290
3291 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003292 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003293 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003294 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003295 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003296
3297 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003298 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003299 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003300 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003301 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003302
3303 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003304 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003305 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003306 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003307 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003308
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003309 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003310 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003311 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3312 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003313 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3314 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003315 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003316
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003317 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003318 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3319 const auto *rasterization_order_attachment_access_feature =
3320 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3321 const bool rasterization_order_depth_attachment_access_feature_enabled =
3322 rasterization_order_attachment_access_feature &&
3323 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3324 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3325 skip |= LogError(
3326 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3327 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3328 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3329 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003330 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003331 }
3332
3333 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3334 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003335 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003336 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3337 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003338 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003339 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3340 }
3341 }
3342
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003343 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003344 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3345 const auto *rasterization_order_attachment_access_feature =
3346 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3347 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3348 rasterization_order_attachment_access_feature &&
3349 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3350 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3351 skip |= LogError(
3352 device,
3353 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3354 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3355 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3356 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003357 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003358 }
3359
3360 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3361 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003362 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003363 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3364 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003365 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003366 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3367 }
3368 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003369 }
3370
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003371 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003372 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3373 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003374
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003375 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3376 skip |=
3377 validate_struct_type("vkCreateGraphicsPipelines",
3378 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3379 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3380 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3381 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003382
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003383 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003384 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003385 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003386 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3387 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003388 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003389 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3390 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003391
Mike Schuchardt00e81452021-11-29 11:11:20 -08003392 skip |= validate_flags("vkCreateGraphicsPipelines",
3393 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3394 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003395 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003396 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003397
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003398 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003399 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3400 const auto *rasterization_order_attachment_access_feature =
3401 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3402 const bool rasterization_order_color_attachment_access_feature_enabled =
3403 rasterization_order_attachment_access_feature &&
3404 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3405
3406 if (!rasterization_order_color_attachment_access_feature_enabled) {
3407 skip |= LogError(
3408 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3409 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3410 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3411 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003412 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003413 }
3414
3415 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003416 skip |=
3417 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3418 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3419 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3420 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3421 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003422 }
3423 }
3424
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003425 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003426 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003428 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429
3430 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003431 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3433 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003434 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3435 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003437 if (create_info.pColorBlendState->pAttachments != NULL) {
3438 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003439 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003440 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003441 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003442 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003443 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003444
3445 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003446 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003447 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003448 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003449 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003450 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003451 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003452
3453 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003454 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003455 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003456 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003457 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003458 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003459 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003460
3461 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003462 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003463 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003464 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003465 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003466 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003467 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003468
3469 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003470 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003471 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003472 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003473 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003474 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003475 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003476
3477 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003478 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003479 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003480 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003481 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003482 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003483 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003484
3485 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003486 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003487 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003488 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003489 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003490 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003491 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003492
3493 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003494 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003496 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003497 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003498 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003499 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003500
3501 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3502 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003503 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003504 case VK_BLEND_OP_ZERO_EXT:
3505 case VK_BLEND_OP_SRC_EXT:
3506 case VK_BLEND_OP_DST_EXT:
3507 case VK_BLEND_OP_SRC_OVER_EXT:
3508 case VK_BLEND_OP_DST_OVER_EXT:
3509 case VK_BLEND_OP_SRC_IN_EXT:
3510 case VK_BLEND_OP_DST_IN_EXT:
3511 case VK_BLEND_OP_SRC_OUT_EXT:
3512 case VK_BLEND_OP_DST_OUT_EXT:
3513 case VK_BLEND_OP_SRC_ATOP_EXT:
3514 case VK_BLEND_OP_DST_ATOP_EXT:
3515 case VK_BLEND_OP_XOR_EXT:
3516 case VK_BLEND_OP_INVERT_EXT:
3517 case VK_BLEND_OP_INVERT_RGB_EXT:
3518 case VK_BLEND_OP_LINEARDODGE_EXT:
3519 case VK_BLEND_OP_LINEARBURN_EXT:
3520 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3521 case VK_BLEND_OP_LINEARLIGHT_EXT:
3522 case VK_BLEND_OP_PINLIGHT_EXT:
3523 case VK_BLEND_OP_HARDMIX_EXT:
3524 case VK_BLEND_OP_PLUS_EXT:
3525 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3526 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3527 case VK_BLEND_OP_PLUS_DARKER_EXT:
3528 case VK_BLEND_OP_MINUS_EXT:
3529 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3530 case VK_BLEND_OP_CONTRAST_EXT:
3531 case VK_BLEND_OP_INVERT_OVG_EXT:
3532 case VK_BLEND_OP_RED_EXT:
3533 case VK_BLEND_OP_GREEN_EXT:
3534 case VK_BLEND_OP_BLUE_EXT:
3535 invalid = true;
3536 break;
3537 default:
3538 break;
3539 }
3540 if (invalid) {
3541 skip |= LogError(
3542 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3543 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3544 "].pColorBlendState->pAttachments[%" PRIu32
3545 "].colorBlendOp (%s) is not valid when "
3546 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3547 "VK_FALSE",
3548 i, attachment_index,
3549 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003550 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003551 }
3552 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003553 }
3554 }
3555
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003556 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003557 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003558 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3559 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003560 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3561 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003562 }
3563
3564 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003565 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003566 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003567 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003568 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003569 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003570 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003571 }
3572 }
3573 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003574
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003575 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003576 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003577 if (create_info.basePipelineIndex != -1) {
3578 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003579 skip |=
3580 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003581 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3582 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003583 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003584 "and pCreateInfos->basePipelineIndex is not -1.",
3585 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003586 }
3587 }
3588
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003589 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3590 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003591 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003592 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3593 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003594 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003595 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3596 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003597 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003598 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003599 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003600 skip |=
3601 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003602 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3603 ") must be a valid"
3604 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003605 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003606 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003607 }
3608 }
3609
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003610 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003611 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003612 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003613 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003614 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3615 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3616 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3617 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003618 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003619 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003620 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003621 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003622 "pCreateInfos[%" PRIu32
3623 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003624 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3625 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003626 }
3627 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003628 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3629 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003630 (physical_device_features.fillModeNonSolid == false)) {
3631 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003632 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3633 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003634 "pCreateInfos[%" PRIu32
3635 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003636 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3637 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003638 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 }
Petr Kraus299ba622017-11-24 03:09:03 +01003640
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003641 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003642 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003643 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3644 "The line width state is static (pCreateInfos[%" PRIu32
3645 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3646 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3647 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003648 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003649 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003650 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003651
3652 // Validate no flags not allowed are used
3653 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003654 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003655 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3656 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003657 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3658 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003659 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003660 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3661 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003662 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003663 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3664 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003665 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3666 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003667 }
3668 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3669 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003670 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3671 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003672 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3673 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003674 }
3675 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3676 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003677 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3678 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003679 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3680 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003681 }
3682 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3683 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003684 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3685 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003686 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3687 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003688 }
3689 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3690 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003691 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3692 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003693 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3694 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003695 }
3696 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3697 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003698 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3699 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003700 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3701 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003702 }
3703 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3704 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003705 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3706 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003707 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3708 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003709 }
3710 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3711 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003712 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3713 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003714 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3715 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003716 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003717 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3718 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3719 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3720 "]->flags (0x%x) must not include "
3721 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3722 i, flags);
3723 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003724 }
3725 }
3726
3727 return skip;
3728}
3729
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003730bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3731 uint32_t createInfoCount,
3732 const VkComputePipelineCreateInfo *pCreateInfos,
3733 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003734 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003735 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003736 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003737 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003738 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003739 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003740 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003741 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3742 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003743 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003744 skip |= LogError(
3745 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3746 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3747 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3748 feedback_count, i);
3749 }
Peter Chen85366392019-05-14 15:20:11 -04003750 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003751
3752 // Make sure compute stage is selected
3753 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003754 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003755 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3756 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003757 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003758 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003759
sfricke-samsungeb549012021-04-16 01:25:51 -07003760 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3761 // Validate no flags not allowed are used
3762 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003763 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3764 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3765 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3766 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003767 }
3768 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3769 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003770 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3771 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003772 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3773 i, flags);
3774 }
3775 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3776 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003777 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3778 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003779 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3780 i, flags);
3781 }
3782 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3783 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003784 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3785 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003786 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3787 i, flags);
3788 }
3789 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3790 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003791 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3792 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003793 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3794 i, flags);
3795 }
3796 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3797 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003798 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3799 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003800 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3801 i, flags);
3802 }
3803 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3804 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003805 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3806 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003807 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3808 i, flags);
3809 }
3810 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3811 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003812 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3813 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003814 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3815 i, flags);
3816 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003817 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3818 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003819 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3820 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003821 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3822 i, flags);
3823 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003824 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3825 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003826 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3827 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003828 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3829 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003830 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003831 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3832 if (pCreateInfos[i].basePipelineIndex != -1) {
3833 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3834 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3835 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3836 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3837 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3838 i);
3839 }
3840 }
3841
3842 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3843 if (pCreateInfos[i].basePipelineIndex != -1) {
3844 skip |= LogError(
3845 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3846 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3847 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3848 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3849 i);
3850 }
3851 } else {
3852 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3853 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3854 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3855 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3856 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3857 }
3858 }
3859 }
ziga-lunargc6341372021-07-28 12:57:42 +02003860
3861 std::stringstream msg;
3862 msg << "pCreateInfos[%" << i << "].stage";
3863 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003864 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003865 return skip;
3866}
3867
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003868bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003869 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003870 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003871
3872 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003873 const auto &features = physical_device_features;
3874 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003875
John Zulauf71968502017-10-26 13:51:15 -06003876 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3877 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003878 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3879 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3880 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3881 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003882 }
3883
3884 // Anistropy cannot be enabled in sampler unless enabled as a feature
3885 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003886 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3887 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3888 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003889 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003890 }
John Zulauf71968502017-10-26 13:51:15 -06003891
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003892 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3893 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003894 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3895 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3896 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3897 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003898 }
3899 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003900 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3901 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3902 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3903 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003904 }
3905 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003906 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3907 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3908 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3909 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003910 }
3911 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3912 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3913 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3914 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003915 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3916 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3917 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3918 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3919 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3920 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003921 }
3922 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003923 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3924 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3925 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003926 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003927 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003928 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3929 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3930 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003931 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003932 }
3933
3934 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003935 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003936 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003937 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3938 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003939 if (sampler_reduction != nullptr) {
3940 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003941 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3942 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
3943 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003944 }
3945 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003946 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003947 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
ziga-lunarg01be97a2022-05-01 14:30:39 +02003948 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
3949 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
3950 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
3951 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
3952 "extension %s is not enabled.",
3953 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3954 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
3955 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
3956 }
3957 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003958 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003959
3960 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3961 // valid VkBorderColor value
3962 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3963 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3964 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003965 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3966 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003967 }
3968
John Zulauf275805c2017-10-26 15:34:49 -06003969 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003970 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003971 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3972 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003973 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3974 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3975 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003976 }
3977 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003978
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003979 // Check for valid Lod range
3980 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003981 skip |=
3982 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3983 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003984 }
3985
3986 // Check mipLodBias to device limit
3987 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003988 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3989 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3990 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003991 }
3992
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003993 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003994 if (sampler_conversion != nullptr) {
3995 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3996 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3997 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3998 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003999 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07004000 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07004001 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
4002 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
4003 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
4004 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
4005 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
4006 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
4007 }
4008 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02004009
4010 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
4011 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
4012 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
4013 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4014 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
4015 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
4016 }
4017 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
4018 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
4019 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4020 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
4021 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
4022 }
4023 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
4024 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
4025 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4026 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
4027 pCreateInfo->minLod, pCreateInfo->maxLod);
4028 }
4029 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
4030 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
4031 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
4032 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
4033 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
4034 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4035 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
4036 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
4037 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
4038 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
4039 }
4040 if (pCreateInfo->anisotropyEnable) {
4041 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
4042 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4043 "pCreateInfo->anisotropyEnable must be VK_FALSE");
4044 }
4045 if (pCreateInfo->compareEnable) {
4046 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
4047 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4048 "pCreateInfo->compareEnable must be VK_FALSE");
4049 }
4050 if (pCreateInfo->unnormalizedCoordinates) {
4051 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
4052 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4053 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
4054 }
4055 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004056
Piers Daniell833b9492021-11-20 11:47:10 -07004057 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
4058 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
4059 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
4060 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4061 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
4062 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
4063 }
4064 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
4065 if (!custom_create_info) {
4066 skip |= LogError(
4067 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
4068 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
4069 "struct in pNext chain.\n",
4070 string_VkBorderColor(pCreateInfo->borderColor));
4071 } else {
4072 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
4073 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
4074 !FormatIsSampledInt(custom_create_info->format)) ||
4075 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
4076 !FormatIsSampledFloat(custom_create_info->format)))) {
4077 skip |=
4078 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06004079 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
4080 "whose type does not match\n",
4081 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07004082 ;
4083 }
4084 }
4085 }
4086
4087 const auto *border_color_component_mapping =
4088 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
4089 if (border_color_component_mapping) {
4090 const auto *border_color_swizzle_features =
4091 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4092 bool border_color_swizzle_features_enabled =
4093 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4094 if (!border_color_swizzle_features_enabled) {
4095 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4096 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4097 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004098 }
4099 }
4100 }
4101
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004102 return skip;
4103}
4104
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004105bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
4106 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4107 const char *func_name) const {
4108 bool skip = false;
4109
4110 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4111 uint32_t mutable_type_count = 0;
4112 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4113 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4114 }
4115 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4116 if (mutable_type_count == 0) {
4117 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4118 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4119 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4120 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4121 "].descriptorTypeCount is 0.",
4122 func_name, i, i);
4123 }
4124 } else {
4125 if (mutable_type_count > 0) {
4126 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4127 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4128 "].descriptorType is %s, but "
4129 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4130 "].descriptorTypeCount is not 0.",
4131 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4132 }
4133 }
4134 }
4135
4136 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4137 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4138 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
4139 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4140 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4141 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4142 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4143 func_name, j, k);
4144 break;
4145 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4146 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4147 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4148 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4149 func_name, j, k);
4150 break;
4151 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4152 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4153 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4154 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4155 func_name, j, k);
4156 break;
4157 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4158 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4159 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4160 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4161 func_name, j, k);
4162 break;
4163 default:
4164 break;
4165 }
4166 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4167 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4168 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4169 skip |=
4170 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4171 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4172 "].pDescriptorTypes[%" PRIu32
4173 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4174 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4175 func_name, j, k, j, l,
4176 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4177 }
4178 }
4179 }
4180 }
4181
4182 return skip;
4183}
4184
Tony-LunarG115f89d2022-06-15 10:53:22 -06004185#ifdef VK_USE_PLATFORM_METAL_EXT
4186bool StatelessValidation::ExportMetalObjectsPNextUtil(VkExportMetalObjectTypeFlagBitsEXT bit, const char *vuid,
4187 const char *api_call, const char *sType, const void *pNext) const {
4188 bool skip = false;
4189 auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pNext);
4190 while (export_metal_object_info) {
4191 if (export_metal_object_info->exportObjectType != bit) {
4192 std::stringstream message;
4193 message << api_call
4194 << " The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose "
4195 "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of "
4196 << sType << " are allowed";
4197 skip |= LogError(device, vuid, message.str().c_str(),
4198 string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType));
4199 }
4200 export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext);
4201 }
4202 return skip;
4203}
4204#endif // VK_USE_PLATFORM_METAL_EXT
4205
4206bool StatelessValidation::manual_PreCallValidateCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo,
4207 const VkAllocationCallbacks *pAllocator,
4208 VkSemaphore *pSemaphore) const {
4209 bool skip = false;
4210#ifdef VK_USE_PLATFORM_METAL_EXT
4211 skip |= ExportMetalObjectsPNextUtil(
4212 VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT, "VUID-VkSemaphoreCreateInfo-pNext-06789",
4213 "vkCreateSemaphore():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT", pCreateInfo->pNext);
4214#endif // VK_USE_PLATFORM_METAL_EXT
4215 return skip;
4216}
4217bool StatelessValidation::manual_PreCallValidateCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo,
4218 const VkAllocationCallbacks *pAllocator, VkEvent *pEvent) const {
4219 bool skip = false;
4220#ifdef VK_USE_PLATFORM_METAL_EXT
4221 skip |= ExportMetalObjectsPNextUtil(
4222 VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT, "VUID-VkEventCreateInfo-pNext-06790",
4223 "vkCreateEvent():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT", pCreateInfo->pNext);
4224#endif // VK_USE_PLATFORM_METAL_EXT
4225 return skip;
4226}
4227bool StatelessValidation::manual_PreCallValidateCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo,
4228 const VkAllocationCallbacks *pAllocator,
4229 VkBufferView *pBufferView) const {
4230 bool skip = false;
4231#ifdef VK_USE_PLATFORM_METAL_EXT
4232 skip |= ExportMetalObjectsPNextUtil(
4233 VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkBufferViewCreateInfo-pNext-06782",
4234 "vkCreateBufferView():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pCreateInfo->pNext);
4235#endif // VK_USE_PLATFORM_METAL_EXT
4236 return skip;
4237}
4238
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004239bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4240 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4241 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004242 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004243 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004244
ziga-lunargfc6896f2021-10-15 18:46:12 +02004245 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4246 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4247 bool mutable_descriptor_type_features_enabled =
4248 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4249
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004250 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4251 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4252 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4253 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004254 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4255 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4256 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4257 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4258 ++descriptor_index) {
4259 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004260 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004261 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004262 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4263 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004264 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004265 }
4266 }
4267 }
4268
4269 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4270 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4271 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004272 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004273 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4274 "].descriptorCount is not 0, "
4275 "pCreateInfo->pBindings[%" PRIu32
4276 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004277 "values.",
4278 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004279 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004280
4281 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4282 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4283 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004284 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4285 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4286 "].descriptorCount is not 0 and "
4287 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4288 "].stageFlags "
4289 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4290 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004291 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004292
4293 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4294 if (!mutable_descriptor_type) {
4295 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4296 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4297 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4298 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4299 i);
4300 }
4301 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4302 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4303 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4304 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4305 "pImmutableSamplers is not NULL.",
4306 i);
4307 }
4308 if (!mutable_descriptor_type_features_enabled) {
4309 skip |= LogError(
4310 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4311 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4312 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4313 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4314 i);
4315 }
4316 }
4317
4318 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4319 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4320 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4321 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4322 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4323 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4324 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004325 }
4326 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004327
4328 if (mutable_descriptor_type) {
4329 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4330 "vkDescriptorSetLayoutCreateInfo");
4331 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004332 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004333 if (pCreateInfo) {
4334 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4335 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4336 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4337 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4338 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4339 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4340 }
4341 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4342 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4343 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4344 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4345 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4346 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4347 }
4348 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4349 !mutable_descriptor_type_features_enabled) {
4350 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4351 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4352 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4353 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4354 }
4355 }
4356
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004357 return skip;
4358}
4359
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004360bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4361 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004362 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004363 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4364 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4365 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004366 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4367 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004368}
4369
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004370bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4371 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004372 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004373 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004374
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004375 if (pDescriptorWrites != NULL) {
4376 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4377 // descriptorCount must be greater than 0
4378 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004379 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4380 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4381 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004382 }
4383
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004384 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004385 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004386 // dstSet must be a valid VkDescriptorSet handle
4387 skip |= validate_required_handle(vkCallingFunction,
4388 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4389 pDescriptorWrites[i].dstSet);
4390 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004391
4392 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4393 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4394 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4395 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4396 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004397 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004398 if (!isPushDescriptor) {
4399 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4400 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4401 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4402 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4403 // ObjectLifetimes::ValidateDescriptorWrite.
4404 skip |= LogError(
4405 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4406 "%s(): if pDescriptorWrites[%" PRIu32
4407 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4408 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4409 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4410 vkCallingFunction, i, i);
4411 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4412 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4413 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4414 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4415 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4416 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4417 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4418 "%s(): if pDescriptorWrites[%" PRIu32
4419 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4420 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4421 "].pImageInfo must not be NULL.",
4422 vkCallingFunction, i, i);
4423 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004424 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4425 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004426 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4427 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004428 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4429 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004430 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004431 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4432 ParameterName::IndexVector{i, descriptor_index}),
4433 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004434 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004435 }
4436 }
4437 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4438 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4439 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4440 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4441 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4442 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4443 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004444 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004445 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004446 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004447 "%s(): if pDescriptorWrites[%" PRIu32
4448 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004449 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4450 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004451 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004452 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004453 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004454 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004455 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004456 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004457 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4458 ++descriptor_index) {
4459 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4460 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4461 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004462 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004463 "%s(): if pDescriptorWrites[%" PRIu32
4464 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004465 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004466 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4467 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004468 }
4469 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004470 }
4471 }
4472 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4473 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004474 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004475 }
4476
4477 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4478 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004479 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004480 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4481 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004482 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004483 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004484 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004485 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004486 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004487 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004488 }
4489 }
4490 }
4491 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4492 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004493 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004494 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4495 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004496 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004497 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004498 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004499 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004500 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004501 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004502 }
4503 }
4504 }
4505 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004506 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4507 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004508 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004509 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004510 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4511 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4512 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4513 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004514 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004515 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4516 pDescriptorWrites[i].descriptorCount);
4517 }
4518 // further checks only if we have right structtype
4519 if (pnext_struct) {
4520 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4521 skip |= LogError(
4522 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004523 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4524 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004525 ".",
4526 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004527 }
sourav parmarbcee7512020-12-28 14:34:49 -08004528 if (pnext_struct->accelerationStructureCount == 0) {
4529 skip |= LogError(device,
4530 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004531 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004532 }
4533 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004534 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004535 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4536 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4537 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4538 skip |= LogError(device,
4539 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4540 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004541 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004542 }
4543 }
4544 }
sourav parmarbcee7512020-12-28 14:34:49 -08004545 }
4546 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004547 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004548 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4549 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4550 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4551 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004552 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004553 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4554 pDescriptorWrites[i].descriptorCount);
4555 }
4556 // further checks only if we have right structtype
4557 if (pnext_struct) {
4558 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4559 skip |= LogError(
4560 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004561 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4562 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004563 ".",
4564 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004565 }
sourav parmarbcee7512020-12-28 14:34:49 -08004566 if (pnext_struct->accelerationStructureCount == 0) {
4567 skip |= LogError(device,
4568 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004569 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004570 }
4571 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004572 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004573 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4574 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4575 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4576 skip |= LogError(device,
4577 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4578 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004579 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004580 }
4581 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004582 }
4583 }
4584 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004585 }
4586 }
4587 return skip;
4588}
4589
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004590bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4591 const VkWriteDescriptorSet *pDescriptorWrites,
4592 uint32_t descriptorCopyCount,
4593 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004594 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004595}
4596
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004597bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004598 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004599 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004600 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4601}
4602
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004603bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4604 const VkAllocationCallbacks *pAllocator,
4605 VkRenderPass *pRenderPass) const {
4606 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4607}
4608
Mike Schuchardt2df08912020-12-15 16:28:09 -08004609bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004610 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004611 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004612 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4613}
4614
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004615bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4616 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004617 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004618 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004619
4620 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4621 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4622 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004623 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4624 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004625 return skip;
4626}
4627
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004628bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004629 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004630 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004631
4632 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4633 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004634 bool cb_is_secondary;
4635 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004636 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004637 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4638 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004639
Tony-LunarG3c287f62020-12-17 12:39:49 -07004640 if (cb_is_secondary) {
4641 // Implicit VUs
4642 // validate only sType here; pointer has to be validated in core_validation
4643 const bool k_not_required = false;
4644 const char *k_no_vuid = nullptr;
4645 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4646 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004647 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4648 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004649
Tony-LunarG3c287f62020-12-17 12:39:49 -07004650 if (info) {
4651 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004652 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004653 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4654 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004655 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004656 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004657 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4658 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4659 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4660 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004661
Tony-LunarG3c287f62020-12-17 12:39:49 -07004662 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004663
Tony-LunarG3c287f62020-12-17 12:39:49 -07004664 // Explicit VUs
4665 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004666 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004667 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4668 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4669 cmd_name);
4670 }
4671
4672 if (physical_device_features.inheritedQueries) {
4673 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004674 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4675 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4676 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004677 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004678 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004679 }
4680
4681 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004682 skip |=
4683 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4684 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4685 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4686 } else { // !pipelineStatisticsQuery
4687 skip |=
4688 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4689 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004690 }
4691
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004692 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004693 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004694 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004695 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4696 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4697 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004698 commandBuffer,
4699 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004700 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4701 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4702 }
Petr Kraus139757b2019-08-15 17:19:33 +02004703 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004704
4705 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4706 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4707 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4708 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4709 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4710 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4711 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4712 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4713 }
Petr Kraus139757b2019-08-15 17:19:33 +02004714 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004715 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004716 return skip;
4717}
4718
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004719bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004720 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004721 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004722
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004723 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004724 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004725 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4726 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4727 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004728 }
4729 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004730 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4731 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4732 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004733 }
4734 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004735 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004736 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004737 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4738 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4739 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4740 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004741 }
4742 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004743
4744 if (pViewports) {
4745 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4746 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004747 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004748 skip |= manual_PreCallValidateViewport(
4749 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004750 }
4751 }
4752
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004753 return skip;
4754}
4755
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004756bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004757 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004758 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004759
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004760 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004761 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004762 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4763 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4764 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004765 }
4766 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004767 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4768 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4769 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004770 }
4771 } else { // multiViewport enabled
4772 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004773 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004774 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4775 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4776 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4777 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004778 }
4779 }
4780
Petr Kraus6260f0a2018-02-27 21:15:55 +01004781 if (pScissors) {
4782 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4783 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004784
Petr Kraus6260f0a2018-02-27 21:15:55 +01004785 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004786 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4787 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4788 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004789 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004790
Petr Kraus6260f0a2018-02-27 21:15:55 +01004791 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004792 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4793 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4794 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004795 }
4796
4797 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4798 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004799 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4800 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4801 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4802 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004803 }
4804
4805 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4806 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004807 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4808 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4809 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4810 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004811 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004812 }
4813 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004814
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004815 return skip;
4816}
4817
Jeff Bolz5c801d12019-10-09 10:38:45 -05004818bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004819 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004820
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004821 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004822 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4823 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004824 }
4825
4826 return skip;
4827}
4828
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004829bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004830 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004831 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004832
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004833 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004834 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004835 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4836 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004837 }
4838 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004839 skip |=
4840 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4841 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4842 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004843 }
4844 return skip;
4845}
4846
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004847bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004848 VkDeviceSize offset, uint32_t drawCount,
4849 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004850 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004851 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004852 skip |=
4853 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4854 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4855 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004856 }
4857 if (drawCount > device_limits.maxDrawIndirectCount) {
4858 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004859 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4860 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004861 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004862 }
4863 return skip;
4864}
4865
sfricke-samsungf692b972020-05-02 08:00:45 -07004866bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4867 VkDeviceSize countBufferOffset, bool khr) const {
4868 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004869 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004870 if (offset & 3) {
4871 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004872 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004873 }
4874
4875 if (countBufferOffset & 3) {
4876 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004877 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004878 countBufferOffset);
4879 }
4880 return skip;
4881}
4882
4883bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4884 VkDeviceSize offset, VkBuffer countBuffer,
4885 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4886 uint32_t stride) const {
4887 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4888}
4889
4890bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4891 VkDeviceSize offset, VkBuffer countBuffer,
4892 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4893 uint32_t stride) const {
4894 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4895}
4896
4897bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4898 VkDeviceSize countBufferOffset, bool khr) const {
4899 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004900 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004901 if (offset & 3) {
4902 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004903 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004904 }
4905
4906 if (countBufferOffset & 3) {
4907 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004908 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004909 countBufferOffset);
4910 }
4911 return skip;
4912}
4913
4914bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4915 VkDeviceSize offset, VkBuffer countBuffer,
4916 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4917 uint32_t stride) const {
4918 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4919}
4920
4921bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4922 VkDeviceSize offset, VkBuffer countBuffer,
4923 VkDeviceSize countBufferOffset,
4924 uint32_t maxDrawCount, uint32_t stride) const {
4925 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4926}
4927
Tony-LunarG4490de42021-06-21 15:49:19 -06004928bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4929 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4930 uint32_t firstInstance, uint32_t stride) const {
4931 bool skip = false;
4932 if (stride & 3) {
4933 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4934 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4935 }
4936 if (drawCount && nullptr == pVertexInfo) {
4937 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4938 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4939 "one or more valid instances of VkMultiDrawInfoEXT structures");
4940 }
4941 return skip;
4942}
4943
4944bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4945 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4946 uint32_t instanceCount, uint32_t firstInstance,
4947 uint32_t stride, const int32_t *pVertexOffset) const {
4948 bool skip = false;
4949 if (stride & 3) {
4950 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4951 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4952 }
4953 if (drawCount && nullptr == pIndexInfo) {
4954 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4955 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4956 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4957 }
4958 return skip;
4959}
4960
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004961bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4962 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004963 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004964 bool skip = false;
4965 for (uint32_t rect = 0; rect < rectCount; rect++) {
4966 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004967 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004968 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004969 }
sfricke-samsung10867682020-04-25 02:20:39 -07004970 if (pRects[rect].rect.extent.width == 0) {
4971 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004972 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004973 }
4974 if (pRects[rect].rect.extent.height == 0) {
4975 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004976 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004977 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004978 }
4979 return skip;
4980}
4981
Andrew Fobel3abeb992020-01-20 16:33:22 -05004982bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4983 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4984 VkImageFormatProperties2 *pImageFormatProperties,
4985 const char *apiName) const {
4986 bool skip = false;
4987
4988 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004989 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004990 if (image_stencil_struct != nullptr) {
4991 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4992 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4993 // No flags other than the legal attachment bits may be set
4994 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4995 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004996 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4997 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4998 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4999 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
5000 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05005001 }
5002 }
5003 }
ziga-lunargd3da2532021-08-11 11:50:12 +02005004 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
5005 if (image_drm_format) {
5006 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5007 skip |= LogError(
5008 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
5009 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
5010 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
5011 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
5012 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02005013 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
5014 skip |= LogError(
5015 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
5016 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
5017 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
5018 apiName, image_drm_format->queueFamilyIndexCount);
5019 }
ziga-lunargd3da2532021-08-11 11:50:12 +02005020 } else {
5021 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5022 skip |= LogError(
5023 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
5024 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
5025 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
5026 apiName);
5027 }
5028 }
5029 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
5030 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
5031 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
5032 if (!format_list || format_list->viewFormatCount == 0) {
5033 skip |= LogError(
5034 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
5035 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
5036 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
5037 apiName);
5038 }
5039 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05005040 }
5041
5042 return skip;
5043}
5044
5045bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
5046 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5047 VkImageFormatProperties2 *pImageFormatProperties) const {
5048 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
5049 "vkGetPhysicalDeviceImageFormatProperties2");
5050}
5051
5052bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
5053 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
5054 VkImageFormatProperties2 *pImageFormatProperties) const {
5055 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
5056 "vkGetPhysicalDeviceImageFormatProperties2KHR");
5057}
5058
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03005059bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
5060 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
5061 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
5062 bool skip = false;
5063
5064 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
5065 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
5066 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
5067 }
5068
5069 return skip;
5070}
5071
sfricke-samsung3999ef62020-02-09 17:05:59 -08005072bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
5073 uint32_t regionCount, const VkBufferCopy *pRegions) const {
5074 bool skip = false;
5075
5076 if (pRegions != nullptr) {
5077 for (uint32_t i = 0; i < regionCount; i++) {
5078 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005079 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005080 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08005081 }
5082 }
5083 }
5084 return skip;
5085}
5086
Jeff Leger178b1e52020-10-05 12:22:23 -04005087bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
5088 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
5089 bool skip = false;
5090
5091 if (pCopyBufferInfo->pRegions != nullptr) {
5092 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5093 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06005094 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005095 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04005096 }
5097 }
5098 }
5099 return skip;
5100}
5101
Tony-LunarGef035472021-11-02 10:23:33 -06005102bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
5103 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
5104 bool skip = false;
5105
5106 if (pCopyBufferInfo->pRegions != nullptr) {
5107 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5108 if (pCopyBufferInfo->pRegions[i].size == 0) {
5109 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
5110 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
5111 }
5112 }
5113 }
5114 return skip;
5115}
5116
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005117bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005118 VkDeviceSize dstOffset, VkDeviceSize dataSize,
5119 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005120 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005121
5122 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005123 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5124 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5125 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005126 }
5127
5128 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005129 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5130 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5131 "), must be greater than zero and less than or equal to 65536.",
5132 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005133 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005134 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5135 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5136 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005137 }
5138 return skip;
5139}
5140
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005141bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005142 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005143 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005144
5145 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005146 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5147 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5148 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005149 }
5150
5151 if (size != VK_WHOLE_SIZE) {
5152 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005153 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005154 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5155 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005156 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005157 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5158 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005159 }
5160 }
5161 return skip;
5162}
5163
sfricke-samsunga1d00272021-03-10 21:37:41 -08005164bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005165 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005166
5167 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005168 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5169 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5170 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5171 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005172 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005173 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5174 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5175 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005176 }
5177
5178 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5179 // queueFamilyIndexCount uint32_t values
5180 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005181 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005182 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005183 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005184 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5185 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005186 }
5187 }
5188
Dave Houlton413a6782018-05-22 13:01:54 -06005189 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005190 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005191
sfricke-samsunga1d00272021-03-10 21:37:41 -08005192 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5193 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5194 if (format_list_info) {
5195 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5196 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5197 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5198 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005199 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5200 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005201 func_name, viewFormatCount);
5202 }
5203
5204 // Using the first format, compare the rest of the formats against it that they are compatible
5205 for (uint32_t i = 1; i < viewFormatCount; i++) {
5206 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5207 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5208 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5209 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005210 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5211 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005212 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5213 string_VkFormat(format_list_info->pViewFormats[i]));
5214 }
5215 }
5216 }
5217
5218 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5219 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5220 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5221 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5222 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5223 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5224 func_name);
5225 } else {
5226 if (format_list_info == nullptr) {
5227 skip |= LogError(
5228 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5229 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5230 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5231 func_name);
5232 } else if (format_list_info->viewFormatCount == 0) {
5233 skip |= LogError(
5234 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5235 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5236 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5237 func_name);
5238 } else {
5239 bool found_base_format = false;
5240 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5241 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5242 found_base_format = true;
5243 break;
5244 }
5245 }
5246 if (!found_base_format) {
5247 skip |=
5248 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5249 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5250 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5251 "pCreateInfo->imageFormat.",
5252 func_name);
5253 }
5254 }
5255 }
5256 }
5257 }
5258 return skip;
5259}
5260
5261bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5262 const VkAllocationCallbacks *pAllocator,
5263 VkSwapchainKHR *pSwapchain) const {
5264 bool skip = false;
5265 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5266 return skip;
5267}
5268
5269bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5270 const VkSwapchainCreateInfoKHR *pCreateInfos,
5271 const VkAllocationCallbacks *pAllocator,
5272 VkSwapchainKHR *pSwapchains) const {
5273 bool skip = false;
5274 if (pCreateInfos) {
5275 for (uint32_t i = 0; i < swapchainCount; i++) {
5276 std::stringstream func_name;
5277 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5278 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5279 }
5280 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005281 return skip;
5282}
5283
Jeff Bolz5c801d12019-10-09 10:38:45 -05005284bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005285 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005286
5287 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005288 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005289 if (present_regions) {
5290 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005291 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005292 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5293 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005294 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005295 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5296 "extension swapchainCount is %i. These values must be equal.",
5297 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005298 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005299 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005300 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5301 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005302 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5303 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5304 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005305 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005306 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005307 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005308 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005309 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005310 }
5311 }
5312
5313 return skip;
5314}
5315
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005316bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5317 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5318 const VkAllocationCallbacks *pAllocator,
5319 VkDisplayModeKHR *pMode) const {
5320 bool skip = false;
5321
5322 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5323 if (display_mode_parameters.visibleRegion.width == 0) {
5324 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5325 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5326 }
5327 if (display_mode_parameters.visibleRegion.height == 0) {
5328 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5329 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5330 }
5331 if (display_mode_parameters.refreshRate == 0) {
5332 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5333 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5334 }
5335
5336 return skip;
5337}
5338
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005339#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005340bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5341 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5342 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005343 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005344 bool skip = false;
5345
5346 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005347 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5348 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005349 }
5350
5351 return skip;
5352}
5353#endif // VK_USE_PLATFORM_WIN32_KHR
5354
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005355static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5356 bool partial_overlap = false;
5357
5358 static const std::vector<VkDescriptorType> all_descriptor_types = {
5359 VK_DESCRIPTOR_TYPE_SAMPLER,
5360 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5361 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5362 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5363 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5364 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5365 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5366 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5367 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5368 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5369 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5370 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5371 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5372 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5373 };
5374
5375 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5376 if (mutable_descriptor_type) {
5377 std::vector<VkDescriptorType> first_types, second_types;
5378 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5379 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5380 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5381 }
5382 } else {
5383 first_types = all_descriptor_types;
5384 }
5385 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5386 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5387 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5388 }
5389 } else {
5390 second_types = all_descriptor_types;
5391 }
5392
5393 bool complete_overlap = first_types.size() == second_types.size();
5394 bool disjoint = true;
5395 for (const auto first_type : first_types) {
5396 bool found = false;
5397 for (const auto second_type : second_types) {
5398 if (first_type == second_type) {
5399 found = true;
5400 break;
5401 }
5402 }
5403 if (found) {
5404 disjoint = false;
5405 } else {
5406 complete_overlap = false;
5407 }
5408 if (!disjoint && !complete_overlap) {
5409 partial_overlap = true;
5410 break;
5411 }
5412 }
5413 }
5414
5415 return partial_overlap;
5416}
5417
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005418bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005419 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005420 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005421 bool skip = false;
5422
5423 if (pCreateInfo) {
5424 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005425 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5426 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005427 }
5428
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005429 const auto *mutable_descriptor_type_features =
5430 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5431 bool mutable_descriptor_type_enabled =
5432 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5433
Petr Krausc8655be2017-09-27 18:56:51 +02005434 if (pCreateInfo->pPoolSizes) {
5435 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5436 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005437 skip |= LogError(
5438 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005439 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005440 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005441 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5442 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005443 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5444 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5445 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5446 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5447 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005448 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005449 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5450 skip |=
5451 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5452 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5453 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5454 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5455 i);
5456 }
5457 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5458 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5459 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5460 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5461 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5462 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5463 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5464 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5465 " and have sets which partially overlap.",
5466 i, j);
5467 }
5468 }
5469 }
5470 }
Petr Krausc8655be2017-09-27 18:56:51 +02005471 }
5472 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005473
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005474 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5475 skip |=
5476 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5477 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5478 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5479 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005480 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5481 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5482 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5483 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5484 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5485 }
Petr Krausc8655be2017-09-27 18:56:51 +02005486 }
5487
5488 return skip;
5489}
5490
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005491bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005492 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005493 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005494
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005495 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005496 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005497 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5498 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5499 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005500 }
5501
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005502 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005503 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005504 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5505 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5506 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005507 }
5508
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005509 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005510 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005511 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5512 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5513 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005514 }
5515
5516 return skip;
5517}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005518
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005519bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005520 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005521 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005522
5523 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005524 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5525 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005526 }
5527 return skip;
5528}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005529
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005530bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5531 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005532 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005533 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005534
5535 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005536 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005537 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005538 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5539 "vkCmdDispatch(): baseGroupX (%" PRIu32
5540 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5541 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005542 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005543 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5544 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5545 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5546 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005547 }
5548
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005549 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005550 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005551 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5552 "vkCmdDispatch(): baseGroupY (%" PRIu32
5553 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5554 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005555 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005556 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5557 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5558 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5559 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005560 }
5561
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005562 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005563 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005564 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5565 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5566 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5567 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005568 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005569 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5570 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5571 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5572 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005573 }
5574
5575 return skip;
5576}
5577
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005578bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5579 VkPipelineBindPoint pipelineBindPoint,
5580 VkPipelineLayout layout, uint32_t set,
5581 uint32_t descriptorWriteCount,
5582 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005583 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005584}
5585
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005586bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5587 uint32_t firstExclusiveScissor,
5588 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005589 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005590 bool skip = false;
5591
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005592 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005593 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005594 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005595 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5596 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5597 ") is not 0.",
5598 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005599 }
5600 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005601 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005602 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5603 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5604 ") is not 1.",
5605 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005606 }
5607 } else { // multiViewport enabled
5608 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005609 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005610 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5611 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5612 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5613 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005614 }
5615 }
5616
Jeff Bolz3e71f782018-08-29 23:15:45 -05005617 if (pExclusiveScissors) {
5618 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5619 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5620
5621 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005622 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5623 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5624 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005625 }
5626
5627 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005628 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5629 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5630 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005631 }
5632
5633 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5634 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005635 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5636 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5637 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5638 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005639 }
5640
5641 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5642 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005643 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5644 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5645 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5646 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005647 }
5648 }
5649 }
5650
5651 return skip;
5652}
5653
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005654bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5655 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005656 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005657 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005658 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5659 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5660 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5661 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5662 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5663 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005664 }
5665
5666 return skip;
5667}
5668
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005669bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5670 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005671 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005672 bool skip = false;
5673
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005674 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005675 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005676 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005677 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5678 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5679 ") is not 0.",
5680 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005681 }
5682 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005683 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005684 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5685 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5686 ") is not 1.",
5687 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005688 }
5689 }
5690
Jeff Bolz9af91c52018-09-01 21:53:57 -05005691 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005692 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005693 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5694 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5695 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5696 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005697 }
5698
5699 return skip;
5700}
5701
Jeff Bolz5c801d12019-10-09 10:38:45 -05005702bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5703 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5704 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005705 bool skip = false;
5706
Dave Houlton142c4cb2018-10-17 15:04:41 -06005707 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005708 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5709 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5710 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005711 }
5712
5713 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005714 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005715 }
5716
5717 return skip;
5718}
5719
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005720bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005721 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005722 bool skip = false;
5723
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005724 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005725 skip |= LogError(
5726 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005727 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5728 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005729 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005730 }
5731
5732 return skip;
5733}
5734
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005735bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5736 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005737 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005738 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005739 static const int condition_multiples = 0b0011;
5740 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005741 skip |= LogError(
5742 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005743 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005744 }
Lockee1c22882019-06-10 16:02:54 -06005745 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005746 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5747 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5748 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5749 stride);
Lockee1c22882019-06-10 16:02:54 -06005750 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005751 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005752 skip |= LogError(
5753 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005754 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5755 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005756 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005757 if (drawCount > device_limits.maxDrawIndirectCount) {
5758 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005759 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5760 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005761 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005762 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005763 return skip;
5764}
5765
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005766bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5767 VkDeviceSize offset, VkBuffer countBuffer,
5768 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005769 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005770 bool skip = false;
5771
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005772 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005773 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5774 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5775 "), is not a multiple of 4.",
5776 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005777 }
5778
5779 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005780 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5781 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5782 "), is not a multiple of 4.",
5783 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005784 }
5785
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005786 return skip;
5787}
5788
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005789bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005790 const VkAllocationCallbacks *pAllocator,
5791 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005792 bool skip = false;
5793
5794 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5795 if (pCreateInfo != nullptr) {
5796 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5797 // VkQueryPipelineStatisticFlagBits values
5798 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5799 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005800 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5801 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5802 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5803 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005804 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005805 if (pCreateInfo->queryCount == 0) {
5806 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5807 "vkCreateQueryPool(): queryCount must be greater than zero.");
5808 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005809 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005810 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005811}
5812
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005813bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5814 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005815 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005816 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5817 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005818}
5819
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005820void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005821 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5822 VkResult result) {
5823 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005824 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005825}
5826
Mike Schuchardt2df08912020-12-15 16:28:09 -08005827void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005828 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5829 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005830 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005831 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005832 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005833}
5834
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005835void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5836 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005837 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005838 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005839 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005840}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005841
Tony-LunarG3c287f62020-12-17 12:39:49 -07005842void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005843 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005844 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005845 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005846 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005847 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005848 }
5849 }
5850}
5851
5852void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005853 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005854 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005855 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5856 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5857 }
5858}
5859
5860void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005861 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005862 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005863 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5864 if (item->second == commandPool) {
5865 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005866 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005867 ++item;
5868 }
5869 }
5870}
5871
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005872bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005873 const VkAllocationCallbacks *pAllocator,
5874 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005875 bool skip = false;
5876
5877 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005878 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005879 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005880 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5881 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005882 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005883
5884 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005885 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005886 if (flags_info) {
5887 flags = flags_info->flags;
5888 }
5889
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005890 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005891 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005892 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005893 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5894 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005895 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005896 }
5897
5898#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005899 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005900#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005901 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5902 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005903#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005904 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005905#endif
5906
5907 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005908 skip |= LogError(
5909 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005910 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5911 }
5912 if (
5913#ifdef VK_USE_PLATFORM_WIN32_KHR
5914 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5915#endif
5916 (import_memory_fd && import_memory_fd->handleType) ||
5917#ifdef VK_USE_PLATFORM_ANDROID_KHR
5918 (import_memory_ahb && import_memory_ahb->buffer) ||
5919#endif
5920 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005921 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5922 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005923 }
5924 }
5925
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005926 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5927 if (export_memory) {
5928 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5929 if (export_memory_nv) {
5930 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5931 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5932 "VkExportMemoryAllocateInfoNV");
5933 }
5934#ifdef VK_USE_PLATFORM_WIN32_KHR
5935 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5936 if (export_memory_win32_nv) {
5937 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5938 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5939 "VkExportMemoryWin32HandleInfoNV");
5940 }
5941#endif
5942 }
5943
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005944 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005945 VkBool32 capture_replay = false;
5946 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005947 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005948 if (vulkan_12_features) {
5949 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5950 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5951 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005952 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005953 if (bda_features) {
5954 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5955 buffer_device_address = bda_features->bufferDeviceAddress;
5956 }
5957 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005958 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005959 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005960 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005961 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005962 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005963 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005964 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005965 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005966 }
5967 }
Tony-LunarG115f89d2022-06-15 10:53:22 -06005968#ifdef VK_USE_PLATFORM_METAL_EXT
5969 skip |= ExportMetalObjectsPNextUtil(
5970 VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT, "VUID-VkMemoryAllocateInfo-pNext-06780",
5971 "vkAllocateMemory():", "VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT", pAllocateInfo->pNext);
5972#endif // VK_USE_PLATFORM_METAL_EXT
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005973 }
5974 return skip;
5975}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005976
Jason Macnak192fa0e2019-07-26 15:07:16 -07005977bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005978 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005979 bool skip = false;
5980
5981 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5982 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5983 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005984 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005985 } else {
5986 uint32_t vertex_component_size = 0;
5987 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5988 vertex_component_size = 4;
5989 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5990 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5991 vertex_component_size = 2;
5992 }
5993 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005994 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005995 }
5996 }
5997
5998 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5999 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006000 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006001 } else {
6002 uint32_t index_element_size = 0;
6003 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
6004 index_element_size = 4;
6005 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
6006 index_element_size = 2;
6007 }
6008 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006009 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006010 }
6011 }
6012 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
6013 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006014 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006015 }
6016 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006017 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006018 }
6019 }
6020
6021 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006022 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006023 }
6024
6025 return skip;
6026}
6027
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006028bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
6029 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006030 bool skip = false;
6031
6032 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006033 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006034 }
6035 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006036 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006037 }
6038
6039 return skip;
6040}
6041
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006042bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
6043 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07006044 bool skip = false;
6045 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006046 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006047 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006048 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006049 }
6050 return skip;
6051}
6052
6053bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07006054 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06006055 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006056 bool skip = false;
6057 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006058 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
6059 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
6060 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07006061 }
6062 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006063 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
6064 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
6065 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07006066 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02006067 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
6068 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
6069 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
6070 }
Jason Macnak5c954952019-07-09 15:46:12 -07006071 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
6072 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006073 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
6074 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
6075 "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 -07006076 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006077 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006078 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06006079 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
6080 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006081 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
6082 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006083 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006084 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006085 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
6086 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
6087 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006088 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006089 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07006090 uint64_t total_triangle_count = 0;
6091 for (uint32_t i = 0; i < info.geometryCount; i++) {
6092 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07006093
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006094 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006095
Jason Macnak5c954952019-07-09 15:46:12 -07006096 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
6097 continue;
6098 }
6099 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
6100 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006101 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006102 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
6103 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
6104 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006105 }
6106 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006107 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
6108 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
6109 for (uint32_t i = 1; i < info.geometryCount; i++) {
6110 const VkGeometryNV &geometry = info.pGeometries[i];
6111 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006112 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006113 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
6114 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006115 "info.pGeometries[0].geometryType.",
6116 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07006117 }
6118 }
6119 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006120 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
6121 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
6122 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
6123 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
6124 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
6125 "or VK_GEOMETRY_TYPE_AABBS_NV.");
6126 }
6127 }
6128 skip |=
6129 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006130 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006131 return skip;
6132}
6133
Ricardo Garciaa4935972019-02-21 17:43:18 +01006134bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6135 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006136 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006137 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006138 if (pCreateInfo) {
6139 if ((pCreateInfo->compactedSize != 0) &&
6140 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006141 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6142 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6143 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6144 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006145 }
Jason Macnak5c954952019-07-09 15:46:12 -07006146
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006147 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006148 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006149 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006150 return skip;
6151}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006152
Jeff Bolz5c801d12019-10-09 10:38:45 -05006153bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6154 const VkAccelerationStructureInfoNV *pInfo,
6155 VkBuffer instanceData, VkDeviceSize instanceOffset,
6156 VkBool32 update, VkAccelerationStructureNV dst,
6157 VkAccelerationStructureNV src, VkBuffer scratch,
6158 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006159 bool skip = false;
6160
6161 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006162 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006163 }
6164
6165 return skip;
6166}
6167
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006168bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6169 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6170 VkAccelerationStructureKHR *pAccelerationStructure) const {
6171 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006172 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006173 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006174 if (!acceleration_structure_features ||
6175 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6176 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6177 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6178 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006179 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006180 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6181 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006182 (acceleration_structure_features &&
6183 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006184 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006185 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6186 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6187 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6188 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006189 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006190 if (pCreateInfo->deviceAddress &&
6191 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6192 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6193 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6194 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6195 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006196 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6197 (acceleration_structure_features &&
6198 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6199 skip |= LogError(
6200 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6201 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6202 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6203 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006204 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6205 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006206 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6207 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006208 }
sourav parmar83c31b12020-05-06 12:30:54 -07006209 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006210 return skip;
6211}
6212
Jason Macnak5c954952019-07-09 15:46:12 -07006213bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6214 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006215 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006216 bool skip = false;
6217 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006218 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6219 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006220 }
6221 return skip;
6222}
6223
sourav parmarcd5fb182020-07-17 12:58:44 -07006224bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6225 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6226 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6227 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006228 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006229 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006230 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006231 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006232 }
6233 return skip;
6234}
6235
Peter Chen85366392019-05-14 15:20:11 -04006236bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6237 uint32_t createInfoCount,
6238 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6239 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006240 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006241 bool skip = false;
6242
6243 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006244 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6245 std::stringstream msg;
6246 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6247 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6248 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006249 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006250 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006251 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006252 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6253 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6254 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6255 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006256 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006257
6258 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006259 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006260 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6261 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6262 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6263 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6264 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6265 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6266 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6267 }
6268 }
6269
sourav parmarf4a78252020-04-10 13:04:21 -07006270 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6271 skip |=
6272 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6273 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6274 }
6275 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6276 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6277 skip |=
6278 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6279 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6280 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6281 }
6282 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6283 if (pCreateInfos[i].basePipelineIndex != -1) {
6284 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6285 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6286 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6287 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6288 "and pCreateInfos->basePipelineIndex is not -1.");
6289 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006290 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006291 skip |=
6292 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6293 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6294 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6295 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6296 "that element.");
6297 }
sourav parmarf4a78252020-04-10 13:04:21 -07006298 }
6299 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006300 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006301 skip |=
6302 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6303 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6304 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6305 "commands pCreateInfos parameter.");
6306 }
6307 } else {
6308 if (pCreateInfos[i].basePipelineIndex != -1) {
6309 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6310 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6311 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6312 }
6313 }
6314 }
6315 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6316 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6317 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6318 }
6319 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6320 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6321 "vkCreateRayTracingPipelinesNV: flags must not include "
6322 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6323 }
6324 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6325 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6326 "vkCreateRayTracingPipelinesNV: flags must not include "
6327 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6328 }
6329 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6330 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6331 "vkCreateRayTracingPipelinesNV: flags must not include "
6332 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6333 }
6334 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6335 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6336 "vkCreateRayTracingPipelinesNV: flags must not include "
6337 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6338 }
6339 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6340 skip |= LogError(
6341 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6342 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6343 }
6344 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6345 skip |= LogError(
6346 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6347 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6348 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006349 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6350 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6351 "vkCreateRayTracingPipelinesNV: flags must not include "
6352 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6353 }
6354 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6355 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6356 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6357 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006358 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6359 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6360 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6361 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6362 }
Peter Chen85366392019-05-14 15:20:11 -04006363 }
6364
6365 return skip;
6366}
6367
sourav parmarcd5fb182020-07-17 12:58:44 -07006368bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6369 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6370 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006371 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006372 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006373 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6374 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6375 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006376 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006377 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006378 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6379 std::stringstream msg;
6380 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6381 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006382 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006383 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006384 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6385 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6386 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6387 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6388 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6389 }
6390 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6391 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6392 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6393 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6394 }
6395 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006396 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006397 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006398 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006399 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6400 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6401 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006402 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6403 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6404 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006405 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006406 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006407 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6408 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6409 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6410 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006411 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006412 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6413 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6414 }
6415 }
sourav parmarf4a78252020-04-10 13:04:21 -07006416 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006417 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6418 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006419 }
6420 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006421 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006422 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006423 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6424 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006425 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006426 }
6427 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6428 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6429 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006430 }
6431 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6432 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6433 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6434 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6435 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6436 skip |= LogError(
6437 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006438 "vkCreateRayTracingPipelinesKHR: If flags includes "
6439 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006440 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6441 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6442 "must not be VK_SHADER_UNUSED_KHR");
6443 }
6444 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6445 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6446 skip |= LogError(
6447 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006448 "vkCreateRayTracingPipelinesKHR: If flags includes "
6449 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006450 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6451 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6452 "element must not be VK_SHADER_UNUSED_KHR");
6453 }
6454 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006455 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6456 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6457 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6458 skip |= LogError(
6459 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6460 "vkCreateRayTracingPipelinesKHR: If "
6461 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6462 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6463 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6464 }
6465 }
sourav parmarf4a78252020-04-10 13:04:21 -07006466 }
6467 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6468 if (pCreateInfos[i].basePipelineIndex != -1) {
6469 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6470 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006471 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006472 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6473 "and pCreateInfos->basePipelineIndex is not -1.");
6474 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006475 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006476 skip |=
6477 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6478 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6479 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6480 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6481 "element.");
6482 }
sourav parmarf4a78252020-04-10 13:04:21 -07006483 }
6484 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006485 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006486 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006487 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006488 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6489 ") must be a valid into the calling"
6490 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006491 pCreateInfos[i].basePipelineIndex, createInfoCount);
6492 }
6493 } else {
6494 if (pCreateInfos[i].basePipelineIndex != -1) {
6495 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006496 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006497 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6498 }
6499 }
6500 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006501 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6502 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6503 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6504 "vkCreateRayTracingPipelinesKHR: If flags includes "
6505 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6506 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006507 }
6508 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6509 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6510 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6511 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6512 "pLibraryInfo and pLibraryInterface must be NULL.");
6513 }
6514 if (pCreateInfos[i].pLibraryInfo) {
6515 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6516 if (pCreateInfos[i].stageCount == 0) {
6517 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6518 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6519 "stageCount must not be 0.");
6520 }
6521 if (pCreateInfos[i].groupCount == 0) {
6522 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6523 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6524 "groupCount must not be 0.");
6525 }
6526 } else {
6527 if (pCreateInfos[i].pLibraryInterface == NULL) {
6528 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6529 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6530 "is greater than 0, its "
6531 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006532 }
6533 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006534 }
6535 if (pCreateInfos[i].pLibraryInterface) {
6536 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6537 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6538 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6539 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6540 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6541 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006542 }
6543 if (deferredOperation != VK_NULL_HANDLE) {
6544 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6545 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6546 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6547 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006548 }
6549 }
ziga-lunargdea76582021-09-17 14:38:08 +02006550 if (pCreateInfos[i].pDynamicState) {
6551 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6552 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6553 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6554 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6555 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6556 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6557 }
6558 }
6559 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006560 }
6561
6562 return skip;
6563}
6564
Mike Schuchardt21638df2019-03-16 10:52:02 -07006565#ifdef VK_USE_PLATFORM_WIN32_KHR
6566bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6567 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006568 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006569 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006570 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006571 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006572 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006573 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006574 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006575 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006576 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006577 skip |=
6578 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006579 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006580 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6581 skip |= validate_struct_type(
6582 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6583 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6584 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6585 if (pSurfaceInfo != NULL) {
6586 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6587 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6588 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6589
6590 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6591 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6592 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6593 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006594 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6595 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006596
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006597 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6598 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6599 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6600 "VK_GOOGLE_surfaceless_query is not enabled.");
6601 }
6602
Mike Schuchardt21638df2019-03-16 10:52:02 -07006603 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6604 }
6605 return skip;
6606}
6607#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006608
6609bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6610 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006611 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006612 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6613 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006614 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006615 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6616 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6617 }
6618 return skip;
6619}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006620
6621bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006622 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006623 bool skip = false;
6624
6625 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006626 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006627 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006628 }
6629
6630 return skip;
6631}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006632
6633bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006634 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006635 bool skip = false;
6636
6637 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006638 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6639 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006640 }
6641
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006642 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006643 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006644 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6645 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006646 }
6647
6648 return skip;
6649}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006650
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006651bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6652 uint32_t bindingCount, const VkBuffer *pBuffers,
6653 const VkDeviceSize *pOffsets) const {
6654 bool skip = false;
6655 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006656 skip |=
6657 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6658 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6659 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006660 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6661 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006662 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6663 ") must be less than "
6664 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006665 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6666 }
6667
Jeff Bolz165818a2020-05-08 11:19:03 -05006668 for (uint32_t i = 0; i < bindingCount; ++i) {
6669 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006670 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006671 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006672 skip |=
6673 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6674 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006675 } else {
6676 if (pOffsets[i] != 0) {
6677 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006678 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6679 "] is not 0",
6680 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006681 }
6682 }
6683 }
6684 }
6685
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006686 return skip;
6687}
6688
Mark Lobodzinski84988402019-09-11 15:27:30 -06006689bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006690 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006691 bool skip = false;
6692 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006693 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6694 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006695 }
6696 return skip;
6697}
6698
6699bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006700 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006701 bool skip = false;
6702 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006703 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6704 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006705 }
6706 return skip;
6707}
Petr Kraus3d720392019-11-13 02:52:39 +01006708
6709bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6710 VkSemaphore semaphore, VkFence fence,
6711 uint32_t *pImageIndex) const {
6712 bool skip = false;
6713
6714 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006715 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6716 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006717 }
6718
6719 return skip;
6720}
6721
6722bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6723 uint32_t *pImageIndex) const {
6724 bool skip = false;
6725
6726 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006727 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6728 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006729 }
6730
6731 return skip;
6732}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006733
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006734bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6735 uint32_t firstBinding, uint32_t bindingCount,
6736 const VkBuffer *pBuffers,
6737 const VkDeviceSize *pOffsets,
6738 const VkDeviceSize *pSizes) const {
6739 bool skip = false;
6740
6741 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6742 for (uint32_t i = 0; i < bindingCount; ++i) {
6743 if (pOffsets[i] & 3) {
6744 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6745 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6746 }
6747 }
6748
6749 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6750 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6751 "%s: The firstBinding(%" PRIu32
6752 ") index is greater than or equal to "
6753 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6754 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6755 }
6756
6757 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6758 skip |=
6759 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6760 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6761 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6762 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6763 }
6764
6765 for (uint32_t i = 0; i < bindingCount; ++i) {
6766 // pSizes is optional and may be nullptr.
6767 if (pSizes != nullptr) {
6768 if (pSizes[i] != VK_WHOLE_SIZE &&
6769 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6770 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6771 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6772 ") is not VK_WHOLE_SIZE and is greater than "
6773 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6774 cmd_name, i, pSizes[i]);
6775 }
6776 }
6777 }
6778
6779 return skip;
6780}
6781
6782bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6783 uint32_t firstCounterBuffer,
6784 uint32_t counterBufferCount,
6785 const VkBuffer *pCounterBuffers,
6786 const VkDeviceSize *pCounterBufferOffsets) const {
6787 bool skip = false;
6788
6789 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6790 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6791 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6792 "%s: The firstCounterBuffer(%" PRIu32
6793 ") index is greater than or equal to "
6794 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6795 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6796 }
6797
6798 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6799 skip |=
6800 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6801 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6802 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6803 cmd_name, firstCounterBuffer, counterBufferCount,
6804 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6805 }
6806
6807 return skip;
6808}
6809
6810bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6811 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6812 const VkBuffer *pCounterBuffers,
6813 const VkDeviceSize *pCounterBufferOffsets) const {
6814 bool skip = false;
6815
6816 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6817 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6818 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6819 "%s: The firstCounterBuffer(%" PRIu32
6820 ") index is greater than or equal to "
6821 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6822 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6823 }
6824
6825 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6826 skip |=
6827 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6828 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6829 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6830 cmd_name, firstCounterBuffer, counterBufferCount,
6831 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6832 }
6833
6834 return skip;
6835}
6836
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006837bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6838 uint32_t firstInstance, VkBuffer counterBuffer,
6839 VkDeviceSize counterBufferOffset,
6840 uint32_t counterOffset, uint32_t vertexStride) const {
6841 bool skip = false;
6842
6843 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006844 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6845 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6846 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6847 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006848 }
6849
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006850 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006851 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006852 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006853 }
6854
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006855 return skip;
6856}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006857
6858bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6859 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6860 const VkAllocationCallbacks *pAllocator,
6861 VkSamplerYcbcrConversion *pYcbcrConversion,
6862 const char *apiName) const {
6863 bool skip = false;
6864
6865 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006866 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006867 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006868 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006869 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6870 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006871 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006872 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006873 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006874
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006875#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006876 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006877 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006878#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006879 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006880#endif
6881
sfricke-samsung1a72f942020-07-25 12:09:18 -07006882 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006883
6884 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006885 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006886 const VkComponentMapping components = pCreateInfo->components;
6887 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6888 if (FormatIsXChromaSubsampled(format) == true) {
6889 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6890 skip |=
6891 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006892 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6893 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006894 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006895 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006896
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006897 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6898 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6899 skip |= LogError(
6900 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6901 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6902 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6903 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6904 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006905
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006906 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6907 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6908 skip |=
6909 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006910 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6911 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006912 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006913 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006914
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006915 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6916 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6917 skip |=
6918 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006919 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6920 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006921 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006922 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006923
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006924 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006925 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6926 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6927 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006928 skip |=
6929 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006930 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6931 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006932 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6933 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006934 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006935 }
6936
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006937 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6938 // Checks same VU multiple ways in order to give a more useful error message
6939 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6940 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6941 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6942 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6943 skip |= LogError(
6944 device, vuid,
6945 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6946 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6947 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6948 string_VkComponentSwizzle(components.b));
6949 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006950
sfricke-samsunged028b02021-09-06 23:14:51 -07006951 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6952 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006953 // 3 = no [a]
6954 // 2 = no [b,a]
6955 // 1 = no [g,b,a]
6956 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006957 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006958
sfricke-samsunged028b02021-09-06 23:14:51 -07006959 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6960 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006961 skip |= LogError(device, vuid,
6962 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6963 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6964 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6965 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006966 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006967 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6968 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6969 skip |= LogError(device, vuid,
6970 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6971 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6972 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6973 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6974 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006975 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006976 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6977 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6978 skip |= LogError(device, vuid,
6979 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6980 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6981 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6982 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6983 string_VkComponentSwizzle(components.b));
6984 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006985 }
6986 }
6987
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006988 return skip;
6989}
6990
6991bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6992 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6993 const VkAllocationCallbacks *pAllocator,
6994 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6995 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6996 "vkCreateSamplerYcbcrConversion");
6997}
6998
6999bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
7000 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
7001 VkSamplerYcbcrConversion *pYcbcrConversion) const {
7002 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
7003 "vkCreateSamplerYcbcrConversionKHR");
7004}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08007005
7006bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
7007 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
7008 bool skip = false;
7009 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
7010 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
7011
7012 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07007013 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
7014 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
7015 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
7016 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
7017 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08007018 }
7019 return skip;
7020}
sourav parmara96ab1a2020-04-25 16:28:23 -07007021
7022bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007023 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007024 bool skip = false;
7025 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
7026 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
7027 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
7028 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007029 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007030 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7031 skip |= LogError(
7032 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
7033 "vkCopyAccelerationStructureToMemoryKHR: The "
7034 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7035 }
7036 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
7037 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
7038 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
7039 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
7040 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
7041 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007042 return skip;
7043}
7044
7045bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
7046 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
7047 bool skip = false;
7048 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
7049 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
7050 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
7051 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
7052 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007053 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
7054 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007055 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007056 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07007057 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007058 return skip;
7059}
7060
7061bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
7062 const char *api_name) const {
7063 bool skip = false;
7064 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
7065 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
7066 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
7067 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
7068 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
7069 api_name);
7070 }
7071 return skip;
7072}
7073
7074bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007075 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007076 bool skip = false;
7077 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007078 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007079 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07007080 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07007081 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
7082 "vkCopyAccelerationStructureKHR: The "
7083 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007084 }
sourav parmara96ab1a2020-04-25 16:28:23 -07007085 return skip;
7086}
7087
7088bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
7089 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
7090 bool skip = false;
7091 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
7092 return skip;
7093}
7094
7095bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06007096 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007097 bool skip = false;
7098 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007099 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07007100 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
7101 }
7102 return skip;
7103}
7104
7105bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007106 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007107 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007108 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007109 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007110 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7111 skip |= LogError(
7112 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
7113 "vkCopyMemoryToAccelerationStructureKHR: The "
7114 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007115 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007116 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
7117 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07007118 return skip;
7119}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06007120
sourav parmara96ab1a2020-04-25 16:28:23 -07007121bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
7122 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
7123 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007124 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07007125 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
7126 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007127 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007128 pInfo->src.deviceAddress);
7129 }
sourav parmar83c31b12020-05-06 12:30:54 -07007130 return skip;
7131}
7132bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7133 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7134 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7135 bool skip = false;
7136 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7137 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007138 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7139 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7140 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7141 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7142 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7143 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7144 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7145 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7146 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7147 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7148 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7149 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7150 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7151 }
sourav parmar83c31b12020-05-06 12:30:54 -07007152 }
7153 return skip;
7154}
7155bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7156 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7157 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7158 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007159 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007160 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7161 skip |= LogError(
7162 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7163 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7164 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7165 }
sourav parmar83c31b12020-05-06 12:30:54 -07007166 if (dataSize < accelerationStructureCount * stride) {
7167 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7168 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007169 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007170 dataSize, accelerationStructureCount, stride);
7171 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007172
sourav parmar83c31b12020-05-06 12:30:54 -07007173 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7174 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007175 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7176 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7177 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7178 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7179 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7180 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7181 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7182 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7183 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7184 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7185 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7186 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7187 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7188 }
sourav parmar83c31b12020-05-06 12:30:54 -07007189 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007190
7191 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7192 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007193 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7194 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7195 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7196 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7197 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007198 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007199 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7200 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7201 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7202 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7203 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007204 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7205 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7206 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7207 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7208 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7209 stride);
7210 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7211 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7212 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7213 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7214 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7215 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007216 }
7217 }
sourav parmar83c31b12020-05-06 12:30:54 -07007218 return skip;
7219}
7220bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7221 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7222 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007223 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007224 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7225 skip |= LogError(
7226 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7227 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7228 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007229 }
7230 return skip;
7231}
7232
7233bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007234 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7235 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7236 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7237 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007238 uint32_t width, uint32_t height, uint32_t depth) const {
7239 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007240 // RayGen
7241 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7242 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7243 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007244 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007245 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7246 0) {
7247 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7248 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7249 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7250 }
7251 // Callable
7252 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7253 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7254 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7255 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007256 }
7257 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7258 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7259 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007260 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7261 }
7262 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7263 0) {
7264 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7265 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7266 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007267 }
7268 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007269 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7270 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7271 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7272 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007273 }
7274 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7275 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007276 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7277 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007278 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007279 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7280 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7281 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7282 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7283 }
sourav parmar83c31b12020-05-06 12:30:54 -07007284 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007285 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7286 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7287 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7288 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007289 }
7290 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7291 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7292 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007293 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7294 }
7295 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7296 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7297 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7298 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7299 }
7300 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007301 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007302 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7303 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7304 }
7305 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7306 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007307 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007308 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7309 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007310 }
7311
sourav parmarcd5fb182020-07-17 12:58:44 -07007312 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7313 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007314 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007315 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7316 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7317 }
7318
7319 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7320 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007321 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007322 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7323 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007324 }
7325 return skip;
7326}
7327
sourav parmarcd5fb182020-07-17 12:58:44 -07007328bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7329 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7330 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7331 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007332 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007333 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007334 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7335 skip |= LogError(
7336 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7337 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7338 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007339 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007340 // RayGen
7341 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7342 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7343 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007344 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007345 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7346 0) {
7347 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7348 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7349 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7350 }
7351 // Callabe
7352 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7353 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7354 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7355 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007356 }
7357 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7358 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007359 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7360 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7361 }
7362 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7363 0) {
7364 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7365 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7366 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007367 }
7368 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007369 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7370 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7371 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7372 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007373 }
7374 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7375 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007376 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7377 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007378 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007379 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7380 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7381 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7382 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7383 }
sourav parmar83c31b12020-05-06 12:30:54 -07007384 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007385 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7386 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7387 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7388 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007389 }
7390 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7391 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007392 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7393 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7394 }
7395 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7396 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7397 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7398 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007399 }
7400
sourav parmarcd5fb182020-07-17 12:58:44 -07007401 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7402 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7403 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007404 }
7405 return skip;
7406}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007407
7408bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7409 VkDeviceAddress indirectDeviceAddress) const {
7410 bool skip = false;
7411 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7412 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7413 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007414 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007415 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7416 "feature must be enabled.");
7417 }
7418
7419 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7420 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7421 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7422 }
7423 return skip;
7424}
7425
sourav parmar83c31b12020-05-06 12:30:54 -07007426bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7427 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7428 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7429 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7430 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7431 uint32_t width, uint32_t height, uint32_t depth) const {
7432 bool skip = false;
7433 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7434 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7435 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7436 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7437 }
7438 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7439 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7440 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7441 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7442 }
7443 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7444 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7445 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7446 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7447 }
7448
7449 // hitShader
7450 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7451 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7452 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7453 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7454 }
7455 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7456 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7457 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7458 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7459 }
7460 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7461 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7462 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7463 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7464 }
7465
7466 // missShader
7467 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7468 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7469 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7470 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7471 }
7472 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7473 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7474 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7475 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7476 }
7477 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7478 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7479 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7480 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7481 }
7482
7483 // raygenShader
7484 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7485 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7486 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007487 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7488 }
7489 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7490 skip |=
7491 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7492 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7493 }
7494 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7495 skip |=
7496 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7497 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7498 }
7499 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7500 skip |=
7501 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7502 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007503 }
7504 return skip;
7505}
7506
sourav parmar83c31b12020-05-06 12:30:54 -07007507bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007508 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7509 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007510 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007511 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7512 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007513 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7514 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007515 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007516 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7517 }
7518 return skip;
7519}
7520
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007521bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7522 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007523 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007524 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007525
7526 if (!physical_device_features.multiViewport) {
7527 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007528 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7529 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007530 viewportCount);
7531 }
7532 } else { // multiViewport enabled
7533 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007534 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7535 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007536 ") must "
7537 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007538 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007539 }
7540 }
7541
7542 if (pViewports) {
7543 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7544 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007545 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007546 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007547 }
7548 }
7549
7550 return skip;
7551}
7552
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007553bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7554 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007555 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007556 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7557 return skip;
7558}
7559
7560bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7561 const VkViewport *pViewports) const {
7562 bool skip = false;
7563 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7564 return skip;
7565}
7566
7567bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7568 const VkRect2D *pScissors, bool is_ext) const {
7569 bool skip = false;
7570 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007571
7572 if (!physical_device_features.multiViewport) {
7573 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007574 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7575 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007576 ") must "
7577 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007578 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007579 }
7580 } else { // multiViewport enabled
7581 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007582 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7583 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007584 ") must "
7585 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007586 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007587 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007588 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7589 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007590 ") must "
7591 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007592 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007593 }
7594 }
7595
7596 if (pScissors) {
7597 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7598 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7599
7600 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007601 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7602 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007603 }
7604
7605 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007606 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7607 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007608 }
7609
7610 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7611 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007612 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7613 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7614 "] will overflow int32_t.",
7615 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007616 }
7617
7618 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7619 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007620 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7621 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7622 "] will overflow int32_t.",
7623 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7624 }
7625 }
7626 }
7627
7628 return skip;
7629}
7630
7631bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7632 const VkRect2D *pScissors) const {
7633 bool skip = false;
7634 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7635 return skip;
7636}
7637
7638bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7639 const VkRect2D *pScissors) const {
7640 bool skip = false;
7641 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7642 return skip;
7643}
7644
7645bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7646 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7647 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7648 bool is_2ext) const {
7649 bool skip = false;
7650 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7651 if (firstBinding >= device_limits.maxVertexInputBindings) {
7652 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7653 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7654 firstBinding, device_limits.maxVertexInputBindings);
7655 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7656 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7657 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7658 ") must be less than "
7659 "maxVertexInputBindings (%" PRIu32 ")",
7660 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7661 }
7662
7663 for (uint32_t i = 0; i < bindingCount; ++i) {
7664 if (pBuffers[i] == VK_NULL_HANDLE) {
7665 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7666 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7667 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7668 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7669 } else {
7670 if (pOffsets[i] != 0) {
7671 skip |=
7672 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7673 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7674 }
7675 }
7676 }
7677 if (pStrides) {
7678 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7679 skip |=
7680 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7681 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7682 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007683 }
7684 }
7685 }
7686
7687 return skip;
7688}
7689
7690bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7691 uint32_t bindingCount, const VkBuffer *pBuffers,
7692 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7693 const VkDeviceSize *pStrides) const {
7694 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007695 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7696 return skip;
7697}
Piers Daniell39842ee2020-07-10 16:42:33 -06007698
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007699bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7700 uint32_t bindingCount, const VkBuffer *pBuffers,
7701 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7702 const VkDeviceSize *pStrides) const {
7703 bool skip = false;
7704 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007705 return skip;
7706}
sourav parmarcd5fb182020-07-17 12:58:44 -07007707
7708bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7709 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7710 bool skip = false;
7711 for (uint32_t i = 0; i < infoCount; ++i) {
7712 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7713 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7714 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7715 }
7716 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7717 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7718 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7719 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7720 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7721 api_name);
7722 }
7723 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7724 skip |=
7725 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7726 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7727 }
7728 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7729 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7730 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7731 }
7732 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7733 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7734 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7735 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7736 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7737 api_name);
7738 }
7739 if (pInfos[i].pGeometries) {
7740 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7741 skip |= validate_ranged_enum(
7742 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7743 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7744 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7745 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007746 skip |= validate_struct_type(
7747 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7748 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7749 &(pInfos[i].pGeometries[j].geometry.triangles),
7750 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7751 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7752 skip |= validate_struct_pnext(
7753 api_name,
7754 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7755 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7756 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7757 skip |=
7758 validate_ranged_enum(api_name,
7759 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7760 ParameterName::IndexVector{i, j}),
7761 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7762 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7763 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7764 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7765 &pInfos[i].pGeometries[j].geometry.triangles,
7766 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7767 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7768 skip |= validate_ranged_enum(
7769 api_name,
7770 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7771 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7772 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7773
7774 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7775 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7776 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7777 }
7778 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7779 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7780 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7781 skip |=
7782 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7783 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7784 api_name);
7785 }
7786 }
7787 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7788 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7789 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7790 &pInfos[i].pGeometries[j].geometry.instances,
7791 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7792 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7793 skip |= validate_struct_type(
7794 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7795 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7796 &(pInfos[i].pGeometries[j].geometry.instances),
7797 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7798 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7799 skip |= validate_struct_pnext(
7800 api_name,
7801 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7802 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7803 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7804
7805 skip |= validate_bool32(api_name,
7806 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7807 ParameterName::IndexVector{i, j}),
7808 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7809 }
7810 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7811 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7812 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7813 &pInfos[i].pGeometries[j].geometry.aabbs,
7814 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7815 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7816 skip |= validate_struct_type(
7817 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7818 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7819 &(pInfos[i].pGeometries[j].geometry.aabbs),
7820 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7821 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7822 skip |= validate_struct_pnext(
7823 api_name,
7824 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7825 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7826 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7827 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7828 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7829 "(%s):stride must be less than or equal to 2^32-1", api_name);
7830 }
7831 }
7832 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7833 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7834 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7835 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7836 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7837 api_name);
7838 }
7839 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7840 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7841 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7842 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7843 "of elements of"
7844 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7845 api_name);
7846 }
7847 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7848 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7849 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7850 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7851 api_name);
7852 }
7853 }
7854 }
7855 }
7856 if (pInfos[i].ppGeometries != NULL) {
7857 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7858 skip |= validate_ranged_enum(
7859 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7860 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7861 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7862 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007863 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7864 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7865 &pInfos[i].ppGeometries[j]->geometry.triangles,
7866 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7867 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7868 skip |= validate_struct_type(
7869 api_name,
7870 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7871 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7872 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7873 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7874 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7875 skip |= validate_struct_pnext(
7876 api_name,
7877 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7878 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7879 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7880 skip |= validate_ranged_enum(api_name,
7881 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7882 ParameterName::IndexVector{i, j}),
7883 "VkFormat", AllVkFormatEnums,
7884 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7885 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7886 skip |= validate_ranged_enum(api_name,
7887 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7888 ParameterName::IndexVector{i, j}),
7889 "VkIndexType", AllVkIndexTypeEnums,
7890 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7891 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7892 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7893 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7894 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7895 }
7896 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7897 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7898 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7899 skip |=
7900 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7901 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7902 api_name);
7903 }
7904 }
7905 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7906 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7907 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7908 &pInfos[i].ppGeometries[j]->geometry.instances,
7909 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7910 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7911 skip |= validate_struct_type(
7912 api_name,
7913 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7914 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7915 &(pInfos[i].ppGeometries[j]->geometry.instances),
7916 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7917 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7918 skip |= validate_struct_pnext(
7919 api_name,
7920 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7921 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7922 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7923 skip |= validate_bool32(api_name,
7924 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7925 ParameterName::IndexVector{i, j}),
7926 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7927 }
7928 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7929 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7930 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7931 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7932 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7933 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7934 skip |= validate_struct_type(
7935 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7936 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7937 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7938 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7939 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7940 skip |= validate_struct_pnext(
7941 api_name,
7942 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7943 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7944 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7945 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7946 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7947 "(%s):stride must be less than or equal to 2^32-1", api_name);
7948 }
7949 }
7950 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7951 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7952 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7953 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7954 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7955 api_name);
7956 }
7957 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7958 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7959 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7960 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7961 "of elements of"
7962 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7963 api_name);
7964 }
7965 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7966 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7967 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7968 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7969 api_name);
7970 }
7971 }
7972 }
7973 }
7974 }
7975 return skip;
7976}
7977bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7978 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7979 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7980 bool skip = false;
7981 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7982 for (uint32_t i = 0; i < infoCount; ++i) {
7983 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7984 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7985 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7986 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7987 "scratchData.deviceAddress member must be a multiple of "
7988 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7989 }
7990 for (uint32_t k = 0; k < infoCount; ++k) {
7991 if (i == k) continue;
7992 bool found = false;
7993 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007994 skip |=
7995 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7996 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7997 ") of pInfos must "
7998 "not be "
7999 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8000 ") of pInfos.",
8001 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008002 found = true;
8003 }
8004 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008005 skip |=
8006 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
8007 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
8008 ") of pInfos must "
8009 "not be "
8010 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8011 ") of pInfos.",
8012 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008013 found = true;
8014 }
8015 if (found) break;
8016 }
8017 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8018 if (pInfos[i].pGeometries) {
8019 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8020 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8021 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8022 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
8023 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8024 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8025 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8026 }
8027 } else {
8028 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8029 skip |=
8030 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
8031 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8032 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8033 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8034 }
8035 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008036 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008037 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8038 skip |= LogError(
8039 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
8040 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8041 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8042 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008043 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8044 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008045 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
8046 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
8047 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8048 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8049 }
8050 }
8051 } else if (pInfos[i].ppGeometries) {
8052 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8053 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8054 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8055 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
8056 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8057 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8058 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8059 }
8060 } else {
8061 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8062 skip |=
8063 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
8064 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8065 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8066 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8067 }
8068 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008069 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008070 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8071 skip |= LogError(
8072 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
8073 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
8074 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8075 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01008076 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8077 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008078 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
8079 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
8080 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8081 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8082 }
8083 }
8084 }
8085 }
8086 }
8087 return skip;
8088}
8089
8090bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
8091 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8092 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
8093 const uint32_t *const *ppMaxPrimitiveCounts) const {
8094 bool skip = false;
8095 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
8096 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008097 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008098 if (!ray_tracing_acceleration_structure_features ||
8099 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
8100 skip |= LogError(
8101 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
8102 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
8103 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
8104 }
8105 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008106 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8107 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8108 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
8109 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
8110 "scratchData.deviceAddress member must be a multiple of "
8111 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8112 }
8113 for (uint32_t k = 0; k < infoCount; ++k) {
8114 if (i == k) continue;
8115 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008116 skip |= LogError(
8117 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
8118 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
8119 ") "
8120 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
8121 "any other element [%" PRIu32 ") of pInfos.",
8122 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008123 break;
8124 }
8125 }
8126 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8127 if (pInfos[i].pGeometries) {
8128 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8129 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8130 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8131 skip |= LogError(
8132 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8133 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8134 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8135 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8136 }
8137 } else {
8138 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8139 skip |= LogError(
8140 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8141 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8142 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8143 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8144 }
8145 }
8146 }
8147 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8148 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8149 skip |= LogError(
8150 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8151 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8152 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8153 }
8154 }
8155 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8156 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8157 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8158 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8159 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8160 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8161 }
8162 }
8163 } else if (pInfos[i].ppGeometries) {
8164 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8165 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8166 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8167 skip |= LogError(
8168 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8169 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8170 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8171 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8172 }
8173 } else {
8174 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8175 skip |= LogError(
8176 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8177 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8178 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8179 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8180 }
8181 }
8182 }
8183 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8184 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8185 skip |= LogError(
8186 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8187 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8188 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8189 }
8190 }
8191 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8192 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8193 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8194 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8195 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8196 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8197 }
8198 }
8199 }
8200 }
8201 }
8202 return skip;
8203}
8204
8205bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8206 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8207 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8208 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8209 bool skip = false;
8210 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8211 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008212 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008213 if (!ray_tracing_acceleration_structure_features ||
8214 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8215 skip |=
8216 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8217 "vkBuildAccelerationStructuresKHR: The "
8218 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8219 }
8220 for (uint32_t i = 0; i < infoCount; ++i) {
8221 for (uint32_t j = 0; j < infoCount; ++j) {
8222 if (i == j) continue;
8223 bool found = false;
8224 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008225 skip |=
8226 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8227 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8228 ") of pInfos must "
8229 "not be "
8230 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8231 ") of pInfos.",
8232 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008233 found = true;
8234 }
8235 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008236 skip |=
8237 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8238 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8239 ") of pInfos must "
8240 "not be "
8241 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8242 ") of pInfos.",
8243 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008244 found = true;
8245 }
8246 if (found) break;
8247 }
8248 }
8249 return skip;
8250}
8251
8252bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8253 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8254 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8255 bool skip = false;
8256 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8257 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008258 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8259 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008260 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8261 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008262 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008263 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8264 }
8265 if (pBuildInfo != nullptr) {
8266 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8267 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8268 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8269 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8270 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008271 }
8272 return skip;
8273}
sfricke-samsungecafb192021-01-17 08:21:14 -08008274
Piers Daniellcb6d8032021-04-19 18:51:26 -06008275bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8276 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8277 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8278 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8279 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008280 const auto *vertex_attribute_divisor_features =
8281 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8282
Piers Daniellcb6d8032021-04-19 18:51:26 -06008283 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8284 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8285 skip |=
8286 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8287 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8288 }
8289
8290 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8291 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8292 skip |= LogError(
8293 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8294 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8295 }
8296
8297 // VUID-vkCmdSetVertexInputEXT-binding-04793
8298 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8299 bool binding_found = false;
8300 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8301 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8302 binding_found = true;
8303 break;
8304 }
8305 }
8306 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008307 skip |= LogError(
8308 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8309 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008310 }
8311 }
8312
8313 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8314 if (vertexBindingDescriptionCount > 1) {
8315 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8316 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8317 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8318 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8319 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008320 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8321 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008322 }
8323 }
8324 }
8325 }
8326
8327 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8328 if (vertexAttributeDescriptionCount > 1) {
8329 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8330 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8331 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8332 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8333 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008334 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8335 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008336 }
8337 }
8338 }
8339 }
8340
8341 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8342 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8343 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008344 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8345 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8346 "].binding is greater than maxVertexInputBindings",
8347 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008348 }
8349
8350 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8351 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008352 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8353 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8354 "].stride is greater than maxVertexInputBindingStride",
8355 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008356 }
8357
8358 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8359 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8360 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8361 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008362 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8363 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008364 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8365 binding);
8366 }
8367
8368 if (pVertexBindingDescriptions[binding].divisor > 1) {
8369 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8370 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8371 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008372 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8373 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008374 "vertexAttributeInstanceRateDivisor is not enabled",
8375 binding);
8376 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008377 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008378 if (pVertexBindingDescriptions[binding].divisor >
8379 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008380 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8381 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8382 "].divisor is greater than maxVertexAttribDivisor",
8383 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008384 }
8385
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008386 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008387 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008388 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8389 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8390 "].divisor is greater than 1 but inputRate "
8391 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8392 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008393 }
8394 }
8395 }
8396 }
8397
8398 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008399 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008400 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008401 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8402 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8403 "].location is greater than maxVertexInputAttributes",
8404 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008405 }
8406
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008407 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008408 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008409 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8410 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8411 "].binding is greater than maxVertexInputBindings",
8412 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008413 }
8414
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008415 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008416 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008417 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8418 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8419 "].offset is greater than maxVertexInputAttributeOffset",
8420 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008421 }
8422
8423 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8424 VkFormatProperties properties;
8425 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8426 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8427 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008428 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8429 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008430 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8431 attribute);
8432 }
8433 }
8434
8435 return skip;
8436}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008437
8438bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8439 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8440 const void *pValues) const {
8441 bool skip = false;
8442 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8443 // Check that offset + size don't exceed the max.
8444 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8445 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008446 skip |=
8447 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8448 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8449 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008450 }
8451 if (size > max_push_constants_size - offset) {
8452 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008453 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8454 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008455 offset, size, max_push_constants_size);
8456 }
8457
8458 // size needs to be non-zero and a multiple of 4.
8459 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008460 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8461 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008462 }
8463
8464 // offset needs to be a multiple of 4.
8465 if ((offset & 0x3) != 0) {
8466 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008467 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008468 }
8469 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008470}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008471
8472bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8473 uint32_t srcCacheCount,
8474 const VkPipelineCache *pSrcCaches) const {
8475 bool skip = false;
8476 if (pSrcCaches) {
8477 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8478 if (pSrcCaches[index0] == dstCache) {
8479 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8480 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8481 report_data->FormatHandle(dstCache).c_str());
8482 break;
8483 }
8484 }
8485 }
8486 return skip;
8487}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008488
8489bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8490 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8491 uint32_t rangeCount,
8492 const VkImageSubresourceRange *pRanges) const {
8493 bool skip = false;
8494 if (!pColor) {
8495 skip |=
8496 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8497 }
8498 return skip;
8499}
8500
8501bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8502 const VkRenderPassBeginInfo *const rp_begin) const {
8503 bool skip = false;
8504 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8505 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8506 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008507 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008508 func_name, rp_begin->clearValueCount);
8509 }
8510 return skip;
8511}
8512
8513bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8514 VkSubpassContents) const {
8515 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8516 return skip;
8517}
8518
8519bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8520 const VkRenderPassBeginInfo *pRenderPassBegin,
8521 const VkSubpassBeginInfo *) const {
8522 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8523 return skip;
8524}
8525
8526bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8527 const VkSubpassBeginInfo *) const {
8528 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8529 return skip;
8530}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008531
8532bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8533 uint32_t firstDiscardRectangle,
8534 uint32_t discardRectangleCount,
8535 const VkRect2D *pDiscardRectangles) const {
8536 bool skip = false;
8537
8538 if (pDiscardRectangles) {
8539 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8540 const int64_t x_sum =
8541 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8542 if (x_sum > std::numeric_limits<int32_t>::max()) {
8543 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8544 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8545 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8546 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8547 }
8548
8549 const int64_t y_sum =
8550 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8551 if (y_sum > std::numeric_limits<int32_t>::max()) {
8552 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8553 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8554 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8555 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8556 }
8557 }
8558 }
8559
8560 return skip;
8561}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008562
8563bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8564 uint32_t queryCount, size_t dataSize, void *pData,
8565 VkDeviceSize stride, VkQueryResultFlags flags) const {
8566 bool skip = false;
8567
8568 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8569 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8570 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8571 }
8572
8573 return skip;
8574}
ziga-lunargcf340c42021-08-19 00:13:38 +02008575
8576bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8577 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8578 bool skip = false;
8579
8580 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8581 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8582 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8583 ") is not a multiple of 4.",
8584 pConditionalRenderingBegin->offset);
8585 }
8586
8587 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008588}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008589
8590bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8591 VkSurfaceKHR surface,
8592 uint32_t *pSurfaceFormatCount,
8593 VkSurfaceFormatKHR *pSurfaceFormats) const {
8594 bool skip = false;
8595 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8596 skip |= LogError(
8597 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8598 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8599 }
8600 return skip;
8601}
8602
8603bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8604 VkSurfaceKHR surface,
8605 uint32_t *pPresentModeCount,
8606 VkPresentModeKHR *pPresentModes) const {
8607 bool skip = false;
8608 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8609 skip |= LogError(
8610 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8611 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8612 }
8613 return skip;
8614}
8615
8616bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8617 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8618 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8619 bool skip = false;
8620 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8621 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8622 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8623 "VK_GOOGLE_surfaceless_query is not enabled.");
8624 }
8625 return skip;
8626}
8627
8628bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8629 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8630 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8631 bool skip = false;
8632 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8633 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8634 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8635 "VK_GOOGLE_surfaceless_query is not enabled.");
8636 }
8637 return skip;
8638}
8639
8640#ifdef VK_USE_PLATFORM_WIN32_KHR
8641bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8642 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8643 VkPresentModeKHR *pPresentModes) const {
8644 bool skip = false;
8645 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8646 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8647 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8648 "VK_GOOGLE_surfaceless_query is not enabled.");
8649 }
8650 return skip;
8651}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008652
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008653#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008654
8655bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8656 const char *func_name) const {
8657 bool skip = false;
8658
8659 if (pInfo && pInfo->pCreateInfo) {
8660 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8661 if (image_swapchain_create_info) {
8662 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8663 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8664 }
sjfricke7f73fbd2022-05-27 06:33:36 +09008665 const auto *drm_format_modifier_create_info =
8666 LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pInfo->pCreateInfo);
8667 if (drm_format_modifier_create_info) {
Mike Schuchardt75a4db52022-06-02 14:01:11 -07008668 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirements-pCreateInfo-06776",
sjfricke7f73fbd2022-05-27 06:33:36 +09008669 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageDrmFormatModifierExplicitCreateInfoEXT.",
8670 func_name);
8671 }
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008672 }
8673
8674 return skip;
8675}
8676
8677bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8678 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8679 bool skip = false;
8680
8681 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8682
8683 return skip;
8684}
8685
8686bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8687 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8688 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8689 bool skip = false;
8690
8691 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8692
8693 return skip;
8694}
Tony-LunarG115f89d2022-06-15 10:53:22 -06008695
8696#ifdef VK_USE_PLATFORM_METAL_EXT
8697bool StatelessValidation::manual_PreCallValidateExportMetalObjectsEXT(VkDevice device,
8698 VkExportMetalObjectsInfoEXT *pMetalObjectsInfo) const {
8699 bool skip = false;
8700 const VkStructureType allowed_structs_vk_export_metal_objects_info[] = {
8701 VK_STRUCTURE_TYPE_EXPORT_METAL_BUFFER_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_COMMAND_QUEUE_INFO_EXT,
8702 VK_STRUCTURE_TYPE_EXPORT_METAL_DEVICE_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_IO_SURFACE_INFO_EXT,
8703 VK_STRUCTURE_TYPE_EXPORT_METAL_SHARED_EVENT_INFO_EXT, VK_STRUCTURE_TYPE_EXPORT_METAL_TEXTURE_INFO_EXT,
8704 };
8705 skip |= validate_struct_pnext("vkExportMetalObjectsEXT", "pMetalObjectsInfo->pNext",
8706 "VkExportMetalBufferInfoEXT, VkExportMetalCommandQueueInfoEXT, VkExportMetalDeviceInfoEXT, "
8707 "VkExportMetalIOSurfaceInfoEXT, VkExportMetalSharedEventInfoEXT, VkExportMetalTextureInfoEXT",
8708 pMetalObjectsInfo->pNext, ARRAY_SIZE(allowed_structs_vk_export_metal_objects_info),
8709 allowed_structs_vk_export_metal_objects_info, GeneratedVulkanHeaderVersion,
8710 "VUID-VkExportMetalObjectsInfoEXT-pNext-pNext", "VUID-VkExportMetalObjectsInfoEXT-sType-unique",
8711 false, true);
8712 return skip;
8713}
8714#endif // VK_USE_PLATFORM_METAL_EXT