blob: 244c3a742ab4735b43ca589dee21a58721f57150 [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
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700172 return skip;
173}
174
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700175void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700176 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
177 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
179 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700180 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700181 this->instance_extensions = instance_data->instance_extensions;
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700182}
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600183
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700184void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) {
185 // Assume phys_devices is valid
186 assert(phys_devices);
187 for (int i = 0; i < count; ++i) {
188 const auto &phys_device = phys_devices[i];
189 if (0 == physical_device_properties_map.count(phys_device)) {
190 auto phys_dev_props = new VkPhysicalDeviceProperties;
191 DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props);
192 physical_device_properties_map[phys_device] = phys_dev_props;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600193
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700194 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
195 uint32_t ext_count = 0;
Jeremy Gebbencbf22862021-03-03 12:01:22 -0700196 layer_data::unordered_set<std::string> dev_exts_enumerated{};
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700197 std::vector<VkExtensionProperties> ext_props{};
198 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr);
199 ext_props.resize(ext_count);
200 instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data());
201 for (uint32_t j = 0; j < ext_count; j++) {
202 dev_exts_enumerated.insert(ext_props[j].extensionName);
203 }
204 device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated);
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600205 }
Nathaniel Cesario645a15b2021-01-08 22:40:21 -0700206 }
207}
208
209void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
210 VkPhysicalDevice *pPhysicalDevices, VkResult result) {
211 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
212 return;
213 }
214
215 if (pPhysicalDeviceCount && pPhysicalDevices) {
216 CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount);
217 }
218}
219
220void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups(
221 VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties,
222 VkResult result) {
223 if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) {
224 return;
225 }
226
227 if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) {
228 for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) {
229 const auto &group = pPhysicalDeviceGroupProperties[i];
230 CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount);
231 }
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600232 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700233}
234
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600235void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
236 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
237 delete (it->second);
238 it = physical_device_properties_map.erase(it);
239 }
240};
241
ziga-lunarg685d5d62022-05-14 00:38:06 +0200242
243void StatelessValidation::GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
244 VkPhysicalDeviceProperties2 &pProperties) const {
245 if (api_version >= VK_API_VERSION_1_1) {
246 DispatchGetPhysicalDeviceProperties2(physicalDevice, &pProperties);
247 } else if (IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) {
248 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &pProperties);
249 }
250}
251
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700252void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700253 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700255 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700256 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
257 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700258
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700259 // Parmeter validation also uses extension data
260 stateless_validation->device_extensions = this->device_extensions;
261
262 VkPhysicalDeviceProperties device_properties = {};
263 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600264 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700265 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
266
sfricke-samsung45996a42021-09-16 13:45:27 -0700267 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700268 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700269 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
270 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200271 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700272 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
273 }
274
sfricke-samsung45996a42021-09-16 13:45:27 -0700275 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700276 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700277 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
278 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200279 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700280 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
281 }
282
sfricke-samsung45996a42021-09-16 13:45:27 -0700283 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700284 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700285 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
286 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200287 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500288 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
289 }
290
sfricke-samsung45996a42021-09-16 13:45:27 -0700291 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500292 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700293 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
294 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200295 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500296 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700297 }
298
sfricke-samsung45996a42021-09-16 13:45:27 -0700299 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700300 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700301 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
302 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200303 GetPhysicalDeviceProperties2(physicalDevice, prop2);
sourav parmarcd5fb182020-07-17 12:58:44 -0700304 phys_dev_ext_props.acc_structure_props = acc_structure_props;
305 }
306
sfricke-samsung45996a42021-09-16 13:45:27 -0700307 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700308 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700309 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
310 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200311 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700312 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
313 }
314
sfricke-samsung45996a42021-09-16 13:45:27 -0700315 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600316 // Get the needed vertex attribute divisor limits
317 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
318 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200319 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Piers Daniellcb6d8032021-04-19 18:51:26 -0600320 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
321 }
322
sfricke-samsung45996a42021-09-16 13:45:27 -0700323 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
Piers Daniella7f93b62021-11-20 12:32:04 -0700324 // Get the needed blend operation advanced properties
ziga-lunarga283d022021-08-04 18:35:23 +0200325 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
326 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200327 GetPhysicalDeviceProperties2(physicalDevice, prop2);
ziga-lunarga283d022021-08-04 18:35:23 +0200328 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
329 }
330
Piers Daniella7f93b62021-11-20 12:32:04 -0700331 if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) {
332 // Get the needed maintenance4 properties
333 auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>();
334 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props);
ziga-lunarg685d5d62022-05-14 00:38:06 +0200335 GetPhysicalDeviceProperties2(physicalDevice, prop2);
Piers Daniella7f93b62021-11-20 12:32:04 -0700336 phys_dev_ext_props.maintenance4_props = maintance4_props;
337 }
338
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800339 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
340
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700341 // Save app-enabled features in this device's validation object
342 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700343 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200344 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
345 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
346 if (features2) {
347 tmp_features2_state.features = features2->features;
348 } else if (pCreateInfo->pEnabledFeatures) {
349 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700350 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200351 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700352 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200353 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700354 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200355 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700356}
357
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700358bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500359 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600360 bool skip = false;
361
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200362 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
363 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
364 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600365 }
366
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700367 // If this device supports VK_KHR_portability_subset, it must be enabled
368 const std::string portability_extension_name("VK_KHR_portability_subset");
369 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
370 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
371 bool portability_requested = false;
372
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200373 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
374 skip |=
375 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
376 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
377 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
378 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700379 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
380 portability_requested = true;
381 }
382 }
383
384 if (portability_supported && !portability_requested) {
385 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
386 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
387 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600388 }
389
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200390 {
aitor-lunargd5301592022-01-05 22:38:16 +0100391 bool maint1 = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700392 bool negative_viewport =
aitor-lunargd5301592022-01-05 22:38:16 +0100393 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
394 if (negative_viewport) {
395 // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to
396 // integration into api version 1.1
397 if (api_version >= VK_API_VERSION_1_1) {
398 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840",
399 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not include "
400 "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1.");
401 } else if (maint1) {
402 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
403 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include "
404 "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height.");
405 }
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200406 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600407 }
408
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600409 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200410 bool khr_bda =
411 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
412 bool ext_bda =
413 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600414 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700415 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
416 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
417 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600418 }
419 }
420
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600421 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
422 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700423 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600424 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800425 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700426 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800427 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700428 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600429 }
430 }
431
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700432 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500433 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700434 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500435 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
436 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
437 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
438 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700439 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700440 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
441 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
442 skip |= LogError(
443 device,
444 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
445 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
446 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700447 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700448 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700449 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600450 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
451 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
452 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600453 }
454
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700455 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700456 if (vulkan_11_features) {
457 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
458 while (current) {
459 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
460 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
461 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
462 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
463 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
464 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700465 skip |= LogError(
466 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700467 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
468 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
469 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
470 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
471 break;
472 }
473 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
474 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800475
476 // Check features are enabled if matching extension is passed in as well
477 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
478 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
479 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
480 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
481 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800482 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476",
sfricke-samsungebda6792021-01-16 08:57:52 -0800483 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
484 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
485 }
486 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700487 }
488
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700489 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700490 if (vulkan_12_features) {
491 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
492 while (current) {
493 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
494 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
495 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
496 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
497 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
498 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
499 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
500 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
501 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
502 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
503 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
504 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
505 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700506 skip |= LogError(
507 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700508 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
509 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
510 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
511 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
512 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
513 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
514 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
515 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
516 break;
517 }
518 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
519 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700520 // Check features are enabled if matching extension is passed in as well
521 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
522 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
523 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
524 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
525 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800526 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831",
sfricke-samsungabab4632020-05-04 06:51:46 -0700527 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
528 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
529 }
530 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
531 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
Mike Schuchardt9969d022021-12-20 15:51:55 -0800532 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832",
sfricke-samsungabab4632020-05-04 06:51:46 -0700533 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
534 "is not VK_TRUE.",
535 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
536 }
537 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
538 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
539 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800540 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833",
sfricke-samsungabab4632020-05-04 06:51:46 -0700541 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
542 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
543 }
544 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
545 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
546 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800547 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834",
sfricke-samsungabab4632020-05-04 06:51:46 -0700548 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
549 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
550 }
551 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
552 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
553 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
554 skip |=
Mike Schuchardt9969d022021-12-20 15:51:55 -0800555 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835",
sfricke-samsungabab4632020-05-04 06:51:46 -0700556 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
557 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
558 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
559 }
560 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200561 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
562 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
563 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
564 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
565 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
566 }
567 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700568 }
569
Tony-LunarG273f32f2021-09-28 08:56:30 -0600570 const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(pCreateInfo->pNext);
571 if (vulkan_13_features) {
572 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
573 while (current) {
574 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES ||
575 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES ||
576 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES ||
577 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES ||
578 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES ||
579 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES ||
580 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES ||
581 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES ||
582 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES ||
583 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES ||
584 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES ||
585 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES ||
586 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES) {
Nathaniel Cesario7a1f5b02022-06-06 12:32:59 -0600587 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-06532",
588 "vkCreateDevice(): %s structure included in VkPhysicalDeviceVulkan13Features' pNext chain.",
589 string_VkStructureType(current->sType));
Tony-LunarG273f32f2021-09-28 08:56:30 -0600590 break;
591 }
592 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
593 }
594 }
595
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600596 // Validate pCreateInfo->pQueueCreateInfos
597 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600598
599 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700600 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
601 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600602 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700603 skip |=
604 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
605 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
606 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
607 "index value.",
608 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600609 }
610
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700611 if (queue_create_info.pQueuePriorities != nullptr) {
612 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
613 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
616 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
617 "] (=%f) is not between 0 and 1 (inclusive).",
618 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600619 }
620 }
621 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700622
623 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700624 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700625 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700626 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700627 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700628 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700629 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700630 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700631 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800632 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700633 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800634 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
635 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700636 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600637 }
638 }
639
sfricke-samsung30a57412020-05-15 21:14:54 -0700640 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700641 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700642 VkBool32 variable_pointers = VK_FALSE;
643 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700644 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700645 variable_pointers = vulkan_11_features->variablePointers;
646 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700647 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700648 variable_pointers = variable_pointers_features->variablePointers;
649 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700650 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700651 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700652 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
653 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
654 }
655
sfricke-samsungfd76c342020-05-29 23:13:43 -0700656 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700657 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700658 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700659 VkBool32 multiview_geometry_shader = VK_FALSE;
660 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700661 if (vulkan_11_features) {
662 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700663 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
664 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700665 } else if (multiview_features) {
666 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700667 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
668 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700669 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700670 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700671 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
672 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
673 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700674 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700675 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
676 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
677 }
678
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600679 return skip;
680}
681
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500682bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700683 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700684 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
685 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
686 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600687 }
688
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700689 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600690}
691
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700692bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500693 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100694 bool skip = false;
695
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600696 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700697 skip |=
698 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600699
700 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
701 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
702 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
703 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700704 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
705 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
706 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600707 }
708
709 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
710 // queueFamilyIndexCount uint32_t values
711 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700712 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
713 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
714 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
715 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600716 }
717 }
718
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700719 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
720 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
721 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
722 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
723 }
724
725 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
726 skip |=
727 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
728 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
729 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
730 }
731
732 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
733 skip |=
734 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
735 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
736 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
737 }
738
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600739 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
740 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
741 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
742 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700743 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
744 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
745 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 }
Piers Daniella7f93b62021-11-20 12:32:04 -0700747
748 const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext);
749 if (maintenance4_features && maintenance4_features->maintenance4) {
750 if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) {
751 skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409",
752 "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size "
753 "VkPhysicalDeviceMaintenance4Properties.maxBufferSize");
754 }
755 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600756 }
757
758 return skip;
759}
760
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700761bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500762 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600763 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600764
765 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800766 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700767 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600768 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
769 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
770 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
771 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700772 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
773 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
774 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600775 }
776
777 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
778 // queueFamilyIndexCount uint32_t values
779 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700780 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
781 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
782 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
783 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600784 }
785 }
786
Dave Houlton413a6782018-05-22 13:01:54 -0600787 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700788 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600789 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600791 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600793
Dave Houlton413a6782018-05-22 13:01:54 -0600794 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700795 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600796 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600798
Dave Houlton130c0212018-01-29 13:39:56 -0700799 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700800 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
801 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700802 skip |= LogError(
803 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600804 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
805 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700806 }
807
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600808 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100809 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
810 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700811 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
812 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
813 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600814 }
815
816 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700817 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100818 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700819 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
820 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
821 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
822 ") are not equal.",
823 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100824 }
825
826 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700827 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
828 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
829 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
830 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100831 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600832 }
833
834 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700835 skip |= LogError(
836 device, "VUID-VkImageCreateInfo-imageType-00957",
837 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600838 }
839 }
840
Dave Houlton130c0212018-01-29 13:39:56 -0700841 // 3D image may have only 1 layer
842 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700843 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
844 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700845 }
846
Dave Houlton130c0212018-01-29 13:39:56 -0700847 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
848 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
849 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
850 // At least one of the legal attachment bits must be set
851 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700852 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
853 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700854 }
855 // No flags other than the legal attachment bits may be set
856 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
857 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700858 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
859 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700860 }
861 }
862
Jeff Bolzef40fec2018-09-01 22:04:34 -0500863 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700864 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500865 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700866 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700867 ? static_cast<uint32_t>(ceil(log2(max_dim)))
868 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
869 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600870 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700871 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
872 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
873 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600874 }
875
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700876 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700877 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
878 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
879 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600880 }
881
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700882 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700883 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
884 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
885 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100886 }
887
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700888 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700889 skip |= LogError(
890 device, "VUID-VkImageCreateInfo-flags-01924",
891 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
892 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
893 }
894
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600895 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
896 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700897 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
898 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
900 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
901 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600902 }
903
904 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700905 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600906 // Linear tiling is unsupported
907 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700908 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700909 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
910 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600911 }
912
913 // Sparse 1D image isn't valid
914 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700915 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
916 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600917 }
918
919 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700920 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700921 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
922 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
923 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600924 }
925
926 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700927 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700928 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
929 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
930 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600931 }
932
933 // Multi-sample 2D image when device doesn't support it
934 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700935 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600936 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
938 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
939 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700940 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600941 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700942 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
943 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
944 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700945 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600946 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700947 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
948 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
949 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700950 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600951 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700952 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
953 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
954 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600955 }
956 }
957 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500958
Jeff Bolz9af91c52018-09-01 21:53:57 -0500959 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
960 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700961 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
962 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
963 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500964 }
965 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700966 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
967 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
968 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500969 }
970 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700971 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
972 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
973 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500974 }
975 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500976
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700977 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600978 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700979 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
980 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
981 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500982 }
983
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700984 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700985 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
986 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800987 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
988 "depth/stencil format.",
989 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500990 }
991
Dave Houlton142c4cb2018-10-17 15:04:41 -0600992 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700993 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
994 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
995 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
996 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500997 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600998 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
1000 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
1001 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
1002 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -05001003 }
1004 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05001005
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001006 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -08001007 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -07001008 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
1009 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -08001010 "format (%s) must be a depth or depth/stencil format.",
1011 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -07001012 }
1013
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001014 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001015 if (image_stencil_struct != nullptr) {
1016 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
1017 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
1018 // No flags other than the legal attachment bits may be set
1019 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
1020 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001021 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
1022 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
1023 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
1024 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001025 }
1026 }
1027
sfricke-samsung61a57c02021-01-10 21:35:12 -08001028 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -05001029 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
1030 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001031 skip |=
1032 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
1033 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1034 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
1035 ") exceeds device "
1036 "maxFramebufferWidth (%" PRIu32 ")",
1037 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001038 }
1039
1040 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001041 skip |=
1042 LogError(device, "VUID-VkImageCreateInfo-format-02537",
1043 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1044 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
1045 ") exceeds device "
1046 "maxFramebufferHeight (%" PRIu32 ")",
1047 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001048 }
1049 }
1050
1051 if (!physical_device_features.shaderStorageImageMultisample &&
1052 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1053 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1054 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001055 LogError(device, "VUID-VkImageCreateInfo-format-02538",
1056 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1057 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
1058 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001059 }
1060
1061 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1062 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001063 skip |= LogError(
1064 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001065 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1066 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1067 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1068 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1069 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001070 skip |= LogError(
1071 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001072 "vkCreateImage(): Depth-stencil image in which usage does not include "
1073 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1074 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1075 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1076 }
1077
1078 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1079 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001080 skip |= LogError(
1081 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001082 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1083 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1084 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1085 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1086 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001087 skip |= LogError(
1088 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001089 "vkCreateImage(): Depth-stencil image in which usage does not include "
1090 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1091 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1092 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1093 }
1094 }
1095 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001096
1097 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1098 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1099 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1100 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1101 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1102 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001103
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001104 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001105 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001106 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1107 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001108 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1109 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1110 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1111 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1112 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1113 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1114 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001115 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001116 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1117 } else if (drm_format_mod_list != nullptr) {
1118 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1119 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1120 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001121 }
1122 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1123 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1124 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1125 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1126 "in the pNext chain");
1127 }
1128 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001129
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001130 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001131 bool image_create_maybe_linear = false;
1132 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1133 image_create_maybe_linear = true;
1134 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1135 image_create_maybe_linear = false;
1136 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1137 image_create_maybe_linear =
1138 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001139 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001140 }
1141
1142 // If multi-sample, validate type, usage, tiling and mip levels.
1143 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001144 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001145 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1146 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1147 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1148 }
1149
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001150 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001151 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1152 image_create_maybe_linear)) {
1153 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1154 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1155 }
1156
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001157 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1158 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1159 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1160 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1161 "imageType must be VK_IMAGE_TYPE_2D.");
1162 }
1163 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1164 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1165 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1166 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1167 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001168 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001169 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001170 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1171 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1172 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1173 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1174 }
1175 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1176 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1177 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1178 "imageType must be VK_IMAGE_TYPE_2D.");
1179 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001180 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001181 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1182 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1183 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1184 }
1185 if (pCreateInfo->mipLevels != 1) {
1186 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001187 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1188 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001189 pCreateInfo->mipLevels);
1190 }
1191 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001192
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001193 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001194 if (swapchain_create_info != nullptr) {
1195 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1196 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1197 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1198 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1199 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1200 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1201
1202 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1203 // also implicitly forces the check above that extent.depth is 1
1204 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1205 string_VkImageType(pCreateInfo->imageType));
1206 }
1207 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001208 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001209 pCreateInfo->mipLevels);
1210 }
1211 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1212 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1213 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1214 }
1215 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1216 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1217 base_message, string_VkImageTiling(pCreateInfo->tiling));
1218 }
1219 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1220 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1221 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1222 }
1223 const VkImageCreateFlags valid_flags =
1224 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001225 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001226 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001227 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001228 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001229 }
1230 }
1231 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001232
1233 // If Chroma subsampled format ( _420_ or _422_ )
1234 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1235 skip |=
1236 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1237 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1238 ") must be a multiple of 2.",
1239 string_VkFormat(image_format), pCreateInfo->extent.width);
1240 }
1241 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1242 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1243 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1244 ") must be a multiple of 2.",
1245 string_VkFormat(image_format), pCreateInfo->extent.height);
1246 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001247
1248 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1249 if (format_list_info) {
1250 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1251 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1252 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1253 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001254 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001255 viewFormatCount);
1256 }
1257 // Check if viewFormatCount is not zero that it is all compatible
1258 for (uint32_t i = 0; i < viewFormatCount; i++) {
Mike Schuchardtb0608492022-04-05 18:52:48 -07001259 const bool class_compatible =
1260 FormatCompatibilityClass(format_list_info->pViewFormats[i]) == FormatCompatibilityClass(image_format);
1261 if (!class_compatible) {
1262 if (image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) {
1263 const bool size_compatible =
1264 FormatIsCompressed(format_list_info->pViewFormats[i])
1265 ? false
1266 : FormatElementSize(format_list_info->pViewFormats[i]) == FormatElementSize(image_format);
1267 if (!size_compatible) {
1268 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1269 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1270 "] (%s) and VkImageCreateInfo::format (%s) are not compatible or size-compatible.",
1271 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1272 }
1273 } else {
1274 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1275 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1276 "] (%s) and VkImageCreateInfo::format (%s) are not compatible.",
1277 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1278 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001279 }
1280 }
1281 }
Younggwan Kimff6495a2021-12-16 20:28:45 +00001282
1283 const auto image_compression_control = LvlFindInChain<VkImageCompressionControlEXT>(pCreateInfo->pNext);
1284 if (image_compression_control) {
1285 constexpr VkImageCompressionFlagsEXT AllVkImageCompressionFlagBitsEXT =
1286 (VK_IMAGE_COMPRESSION_DEFAULT_EXT | VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT |
1287 VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT | VK_IMAGE_COMPRESSION_DISABLED_EXT);
1288 skip |= validate_flags("vkCreateImage", "VkImageCompressionControlEXT::flags", "VkImageCompressionFlagsEXT",
1289 AllVkImageCompressionFlagBitsEXT, image_compression_control->flags, kRequiredSingleBit,
1290 "VUID-VkImageCompressionControlEXT-flags-06747");
1291
1292 if (image_compression_control->flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT &&
1293 !image_compression_control->pFixedRateFlags) {
1294 skip |= LogError(
1295 device, "VUID-VkImageCompressionControlEXT-flags-06748",
1296 "VkImageCompressionControlEXT::pFixedRateFlags is nullptr even though VkImageCompressionControlEXT::flags are %s",
1297 string_VkImageCompressionFlagsEXT(image_compression_control->flags).c_str());
1298 }
1299 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001300 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001301
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001302 return skip;
1303}
1304
Jeff Bolz99e3f632020-03-24 22:59:22 -05001305bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1306 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1307 bool skip = false;
1308
1309 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001310 // Validate feature set if using CUBE_ARRAY
1311 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1312 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1313 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1314 "enabling the imageCubeArray feature.");
1315 }
1316
Jeff Bolz99e3f632020-03-24 22:59:22 -05001317 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1318 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1319 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001320 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1321 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001322 pCreateInfo->subresourceRange.layerCount);
1323 }
1324 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001325 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1326 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1327 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1328 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001329 }
1330 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001331
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001332 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001333 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001334 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1335 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1336 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1337 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1338 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1339 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1340 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001341 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1342 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001343 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1344 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1345 "not an ASTC format.",
1346 string_VkFormat(pCreateInfo->format));
1347 }
1348 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001349
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001350 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001351 if (ycbcr_conversion != nullptr) {
1352 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1353 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1354 skip |= LogError(
1355 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1356 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1357 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1358 "r swizzle = %s\n"
1359 "g swizzle = %s\n"
1360 "b swizzle = %s\n"
1361 "a swizzle = %s\n",
1362 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1363 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1364 }
1365 }
1366 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001367 }
1368 return skip;
1369}
1370
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001371bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001372 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001373 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001374
1375 // Note: for numerical correctness
1376 // - float comparisons should expect NaN (comparison always false).
1377 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1378
1379 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001380 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001381 if (v1_f <= 0.0f) return true;
1382
1383 float intpart;
1384 const float fract = modff(v1_f, &intpart);
1385
1386 assert(std::numeric_limits<float>::radix == 2);
1387 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1388 if (intpart >= u32_max_plus1) return false;
1389
1390 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001391 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001392 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001393 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001394 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001395 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001396 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001397 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001398 };
1399
1400 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1401 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1402 return (v1_f <= v2_f);
1403 };
1404
1405 // width
1406 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001407 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001408
1409 if (!(viewport.width > 0.0f)) {
1410 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001411 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1412 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001413 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1414 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001415 skip |= LogError(object, "VUID-VkViewport-width-01771",
1416 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1417 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001418 }
1419
1420 // height
1421 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001422 const bool negative_height_enabled =
1423 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001424 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001425
1426 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1427 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001428 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1429 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001430 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1431 height_healthy = false;
1432
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001433 skip |= LogError(object, "VUID-VkViewport-height-01773",
1434 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1435 ").",
1436 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001437 }
1438
1439 // x
1440 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001441 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001442 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001443 skip |= LogError(object, "VUID-VkViewport-x-01774",
1444 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1445 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001446 }
1447
1448 // x + width
1449 if (x_healthy && width_healthy) {
1450 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001451 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001452 skip |= LogError(
1453 object, "VUID-VkViewport-x-01232",
1454 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1455 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1456 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001457 }
1458 }
1459
1460 // y
1461 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001462 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001463 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001464 skip |= LogError(object, "VUID-VkViewport-y-01775",
1465 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1466 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001467 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001468 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001469 skip |= LogError(object, "VUID-VkViewport-y-01776",
1470 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1471 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001472 }
1473
1474 // y + height
1475 if (y_healthy && height_healthy) {
1476 const float boundary = viewport.y + viewport.height;
1477
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001478 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001479 skip |= LogError(object, "VUID-VkViewport-y-01233",
1480 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1481 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1482 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001483 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001484 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001485 LogError(object, "VUID-VkViewport-y-01777",
1486 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1487 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1488 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001489 }
1490 }
1491
sfricke-samsungfd06d422021-01-22 02:17:21 -08001492 // 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 -07001493 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001494 // minDepth
1495 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001496 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001497 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001498 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1499 "[0.0, 1.0] range.",
1500 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001501 }
1502
1503 // maxDepth
1504 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001505 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001506 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001507 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1508 "[0.0, 1.0] range.",
1509 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001510 }
1511 }
1512
1513 return skip;
1514}
1515
Dave Houlton142c4cb2018-10-17 15:04:41 -06001516struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001517 VkShadingRatePaletteEntryNV shadingRate;
1518 uint32_t width;
1519 uint32_t height;
1520};
1521
1522// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001523static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001524 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1525 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1526 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1527 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1528 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1529 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001530};
1531
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001532bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001533 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001534
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001535 SampleOrderInfo *sample_order_info;
1536 uint32_t info_idx = 0;
1537 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1538 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1539 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001540 break;
1541 }
1542 }
1543
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001544 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001545 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1546 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1547 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001548 return skip;
1549 }
1550
Dave Houlton142c4cb2018-10-17 15:04:41 -06001551 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001552 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001553 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1554 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1555 ") must "
1556 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1557 "is set in framebufferNoAttachmentsSampleCounts.",
1558 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001559 }
1560
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001561 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001562 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1563 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1564 ") must "
1565 "be equal to the product of sampleCount (=%" PRIu32
1566 "), the fragment width for shadingRate "
1567 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001568 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001569 }
1570
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001571 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001572 skip |= LogError(
1573 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001574 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1575 ") must "
1576 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001577 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001578 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001579
1580 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001581 // the first width*height*sampleCount bits to all be set. Note: There is no
1582 // guarantee that 64 bits is enough, but practically it's unlikely for an
1583 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001584 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001585 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001586 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001587 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1588 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001589 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1590 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001591 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001592 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001593 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1594 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001595 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001596 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001597 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1598 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001599 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001600 uint32_t idx =
1601 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1602 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001603 }
1604
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001605 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1606 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001607 skip |= LogError(
1608 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001609 "The array pSampleLocations must contain exactly one entry for "
1610 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001611 }
1612
1613 return skip;
1614}
1615
sfricke-samsung51303fb2021-05-09 19:09:13 -07001616bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1617 const VkAllocationCallbacks *pAllocator,
1618 VkPipelineLayout *pPipelineLayout) const {
1619 bool skip = false;
1620 // Validate layout count against device physical limit
1621 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1622 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001623 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1624 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001625 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1626 }
1627
Nathaniel Cesario73c994c2022-05-26 23:07:34 -06001628 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001629 for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
1630 if (!pCreateInfo->pSetLayouts[i]) {
Nathaniel Cesario73c994c2022-05-26 23:07:34 -06001631 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561",
1632 "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32
1633 "] is VK_NULL_HANDLE, but VK_EXT_graphics_pipeline_library is not enabled.",
1634 i);
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001635 }
1636 }
1637 }
1638
sfricke-samsung51303fb2021-05-09 19:09:13 -07001639 // Validate Push Constant ranges
1640 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1641 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1642 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1643 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1644 // Check that offset + size don't exceed the max.
1645 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1646 if (offset >= max_push_constants_size) {
1647 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001648 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1649 ") that exceeds this "
1650 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001651 i, offset, max_push_constants_size);
1652 }
1653 if (size > max_push_constants_size - offset) {
1654 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001655 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1656 ") and size (%" PRIu32
1657 ") "
1658 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001659 i, offset, size, max_push_constants_size);
1660 }
1661
1662 // size needs to be non-zero and a multiple of 4.
1663 if (size == 0) {
1664 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001665 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1666 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001667 i, size);
1668 }
1669 if (size & 0x3) {
1670 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001671 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1672 ") is not a multiple of 4.",
1673 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001674 }
1675
1676 // offset needs to be a multiple of 4.
1677 if ((offset & 0x3) != 0) {
1678 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001679 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1680 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001681 i, offset);
1682 }
1683 }
1684
1685 // 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.
1686 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1687 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1688 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001689 skip |=
1690 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1691 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001692 }
1693 }
1694 }
1695 return skip;
1696}
1697
ziga-lunargc6341372021-07-28 12:57:42 +02001698bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1699 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1700 bool skip = false;
1701
1702 const auto *required_subgroup_size_features =
1703 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1704
1705 if (required_subgroup_size_features) {
1706 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1707 skip |= LogError(
1708 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1709 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1710 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1711 func_name, msg, pCreateInfo->flags);
1712 }
1713 }
1714
1715 return skip;
1716}
1717
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001718bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1719 uint32_t createInfoCount,
1720 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1721 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001722 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001723 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001724
1725 if (pCreateInfos != nullptr) {
1726 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001727 bool has_dynamic_viewport = false;
1728 bool has_dynamic_scissor = false;
1729 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001730 bool has_dynamic_depth_bias = false;
1731 bool has_dynamic_blend_constant = false;
1732 bool has_dynamic_depth_bounds = false;
1733 bool has_dynamic_stencil_compare = false;
1734 bool has_dynamic_stencil_write = false;
1735 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001736 bool has_dynamic_viewport_w_scaling_nv = false;
1737 bool has_dynamic_discard_rectangle_ext = false;
1738 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001739 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001740 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001741 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001742 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001743 bool has_dynamic_cull_mode = false;
1744 bool has_dynamic_front_face = false;
1745 bool has_dynamic_primitive_topology = false;
1746 bool has_dynamic_viewport_with_count = false;
1747 bool has_dynamic_scissor_with_count = false;
1748 bool has_dynamic_vertex_input_binding_stride = false;
1749 bool has_dynamic_depth_test_enable = false;
1750 bool has_dynamic_depth_write_enable = false;
1751 bool has_dynamic_depth_compare_op = false;
1752 bool has_dynamic_depth_bounds_test_enable = false;
1753 bool has_dynamic_stencil_test_enable = false;
1754 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001755 bool has_patch_control_points = false;
1756 bool has_rasterizer_discard_enable = false;
1757 bool has_depth_bias_enable = false;
1758 bool has_logic_op = false;
1759 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001760 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001761
1762 // Create a copy of create_info and set non-included sub-state to null
1763 auto create_info = pCreateInfos[i];
1764 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1765 if (graphics_lib_info) {
Nathaniel Cesariobcb79682022-03-31 21:13:52 -06001766 // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries
1767 if (enabled[gpu_validation]) {
1768 skip |=
1769 LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported");
1770 }
1771 if (enabled[gpu_validation]) {
1772 skip |= LogError(device, kVUIDUndefined,
1773 "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported");
1774 }
1775
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001776 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1777 create_info.pVertexInputState = nullptr;
1778 create_info.pInputAssemblyState = nullptr;
1779 }
1780 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1781 create_info.pViewportState = nullptr;
1782 create_info.pRasterizationState = nullptr;
1783 create_info.pTessellationState = nullptr;
1784 }
1785 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1786 create_info.pDepthStencilState = nullptr;
1787 }
1788 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1789 create_info.pColorBlendState = nullptr;
1790 }
1791 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1792 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1793 create_info.pMultisampleState = nullptr;
1794 }
1795 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1796 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1797 create_info.layout = VK_NULL_HANDLE;
1798 }
1799 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1800 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1801 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1802 create_info.renderPass = VK_NULL_HANDLE;
1803 create_info.subpass = 0;
1804 }
1805 }
1806
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001807 if (!create_info.renderPass) {
1808 if (create_info.pColorBlendState && create_info.pMultisampleState) {
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001809 const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext);
ziga-lunarg97584c32022-04-22 14:33:37 +02001810 // Pipeline has fragment output state
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001811 if (rendering_struct) {
1812 if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1813 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1814 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1815 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001816
1817 if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) {
1818 skip |= LogError(
1819 device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587",
1820 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1821 "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.",
1822 i, string_VkFormat(rendering_struct->depthAttachmentFormat));
1823 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001824 }
1825
1826 if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1827 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1828 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1829 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001830 if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) {
Nathaniel Cesario1ba7ca52022-04-18 12:35:00 -06001831 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588",
1832 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1833 "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a "
1834 "stencil aspect.",
1835 i, string_VkFormat(rendering_struct->stencilAttachmentFormat));
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001836 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001837 }
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001838
1839 if (rendering_struct->colorAttachmentCount != 0) {
1840 skip |= validate_ranged_enum_array(
1841 "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579",
1842 "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums,
1843 rendering_struct->colorAttachmentCount, rendering_struct->pColorAttachmentFormats, true, true);
1844 }
ziga-lunarg97584c32022-04-22 14:33:37 +02001845
1846 if (rendering_struct->pColorAttachmentFormats) {
1847 for (uint32_t j = 0; j < rendering_struct->colorAttachmentCount; ++j) {
1848 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "pColorAttachmentFormats", "VkFormat",
1849 AllVkFormatEnums, rendering_struct->pColorAttachmentFormats[j],
1850 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
1851 }
1852 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001853 }
ziga-lunarg47258542022-04-22 17:40:43 +02001854
1855 // VkAttachmentSampleCountInfoAMD == VkAttachmentSampleCountInfoNV
1856 auto attachment_sample_count_info = LvlFindInChain<VkAttachmentSampleCountInfoAMD>(create_info.pNext);
1857 if (attachment_sample_count_info && attachment_sample_count_info->pColorAttachmentSamples) {
1858 for (uint32_t j = 0; j < attachment_sample_count_info->colorAttachmentCount; ++j) {
1859 skip |= validate_flags("vkCreateGraphicsPipelines",
1860 ParameterName("VkAttachmentSampleCountInfoAMD->pColorAttachmentSamples"),
1861 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
1862 attachment_sample_count_info->pColorAttachmentSamples[j], kRequiredFlags,
1863 "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
1864 }
1865 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001866 }
1867 }
1868
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001869 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1870 if (create_info.stageCount == 0) {
1871 skip |=
1872 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1873 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1874 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1875 }
1876 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1877 // ParameterName::IndexFormatSpecifier
1878 skip |= validate_struct_type_array(
1879 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1880 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
1881 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages,
1882 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1883 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06001884 "VUID-VkGraphicsPipelineCreateInfo-pStages-06600");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001885 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1886 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1887 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
1888 pCreateInfos[i].pRasterizationState,
1889 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1890 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1891 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001892 }
1893
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001894 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1895 if (create_info.pDynamicState != nullptr) {
1896 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001897 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1898 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001899 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1900 if (has_dynamic_viewport == true) {
1901 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1902 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001903 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001904 i);
1905 }
1906 has_dynamic_viewport = true;
1907 }
1908 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1909 if (has_dynamic_scissor == true) {
1910 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1911 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001912 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001913 i);
1914 }
1915 has_dynamic_scissor = true;
1916 }
1917 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1918 if (has_dynamic_line_width == true) {
1919 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1920 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001921 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001922 i);
1923 }
1924 has_dynamic_line_width = true;
1925 }
1926 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1927 if (has_dynamic_depth_bias == true) {
1928 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1929 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001930 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001931 i);
1932 }
1933 has_dynamic_depth_bias = true;
1934 }
1935 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1936 if (has_dynamic_blend_constant == true) {
1937 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1938 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001939 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001940 i);
1941 }
1942 has_dynamic_blend_constant = true;
1943 }
1944 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1945 if (has_dynamic_depth_bounds == true) {
1946 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1947 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001948 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001949 i);
1950 }
1951 has_dynamic_depth_bounds = true;
1952 }
1953 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1954 if (has_dynamic_stencil_compare == true) {
1955 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1956 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001957 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001958 i);
1959 }
1960 has_dynamic_stencil_compare = true;
1961 }
1962 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1963 if (has_dynamic_stencil_write == true) {
1964 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1965 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001966 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001967 i);
1968 }
1969 has_dynamic_stencil_write = true;
1970 }
1971 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1972 if (has_dynamic_stencil_reference == true) {
1973 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1974 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001975 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001976 i);
1977 }
1978 has_dynamic_stencil_reference = true;
1979 }
1980 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1981 if (has_dynamic_viewport_w_scaling_nv == true) {
1982 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1983 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001984 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001985 i);
1986 }
1987 has_dynamic_viewport_w_scaling_nv = true;
1988 }
1989 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1990 if (has_dynamic_discard_rectangle_ext == true) {
1991 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1992 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001993 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001994 i);
1995 }
1996 has_dynamic_discard_rectangle_ext = true;
1997 }
1998 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1999 if (has_dynamic_sample_locations_ext == true) {
2000 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2001 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002002 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002003 i);
2004 }
2005 has_dynamic_sample_locations_ext = true;
2006 }
2007 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
2008 if (has_dynamic_exclusive_scissor_nv == true) {
2009 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2010 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002011 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002012 i);
2013 }
2014 has_dynamic_exclusive_scissor_nv = true;
2015 }
2016 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
2017 if (has_dynamic_shading_rate_palette_nv == true) {
2018 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2019 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002020 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002021 i);
2022 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06002023 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07002024 }
2025 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
2026 if (has_dynamic_viewport_course_sample_order_nv == true) {
2027 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2028 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002029 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002030 i);
2031 }
2032 has_dynamic_viewport_course_sample_order_nv = true;
2033 }
2034 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
2035 if (has_dynamic_line_stipple == true) {
2036 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2037 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002038 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002039 i);
2040 }
2041 has_dynamic_line_stipple = true;
2042 }
Piers Daniell39842ee2020-07-10 16:42:33 -06002043 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
2044 if (has_dynamic_cull_mode) {
2045 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2046 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002047 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002048 i);
2049 }
2050 has_dynamic_cull_mode = true;
2051 }
2052 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
2053 if (has_dynamic_front_face) {
2054 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2055 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002056 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002057 i);
2058 }
2059 has_dynamic_front_face = true;
2060 }
2061 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
2062 if (has_dynamic_primitive_topology) {
2063 skip |= LogError(
2064 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2065 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002066 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002067 i);
2068 }
2069 has_dynamic_primitive_topology = true;
2070 }
2071 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2072 if (has_dynamic_viewport_with_count) {
2073 skip |= LogError(
2074 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2075 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002076 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002077 i);
2078 }
2079 has_dynamic_viewport_with_count = true;
2080 }
2081 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2082 if (has_dynamic_scissor_with_count) {
2083 skip |= LogError(
2084 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2085 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002086 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002087 i);
2088 }
2089 has_dynamic_scissor_with_count = true;
2090 }
2091 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2092 if (has_dynamic_vertex_input_binding_stride) {
2093 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2094 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2095 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002096 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002097 i);
2098 }
2099 has_dynamic_vertex_input_binding_stride = true;
2100 }
2101 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2102 if (has_dynamic_depth_test_enable) {
2103 skip |= LogError(
2104 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2105 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002106 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002107 i);
2108 }
2109 has_dynamic_depth_test_enable = true;
2110 }
2111 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2112 if (has_dynamic_depth_write_enable) {
2113 skip |= LogError(
2114 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2115 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002116 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002117 i);
2118 }
2119 has_dynamic_depth_write_enable = true;
2120 }
2121 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2122 if (has_dynamic_depth_compare_op) {
2123 skip |=
2124 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2125 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002126 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002127 i);
2128 }
2129 has_dynamic_depth_compare_op = true;
2130 }
2131 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2132 if (has_dynamic_depth_bounds_test_enable) {
2133 skip |= LogError(
2134 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2135 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002136 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002137 i);
2138 }
2139 has_dynamic_depth_bounds_test_enable = true;
2140 }
2141 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2142 if (has_dynamic_stencil_test_enable) {
2143 skip |= LogError(
2144 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2145 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002146 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002147 i);
2148 }
2149 has_dynamic_stencil_test_enable = true;
2150 }
2151 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2152 if (has_dynamic_stencil_op) {
2153 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2154 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002155 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002156 i);
2157 }
2158 has_dynamic_stencil_op = true;
2159 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002160 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2161 // Not allowed for graphics pipelines
2162 skip |= LogError(
2163 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2164 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002165 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2166 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002167 i, state_index);
2168 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002169 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2170 if (has_patch_control_points) {
2171 skip |= LogError(
2172 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2173 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002174 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002175 i);
2176 }
2177 has_patch_control_points = true;
2178 }
2179 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2180 if (has_rasterizer_discard_enable) {
2181 skip |= LogError(
2182 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2183 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002184 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002185 i);
2186 }
2187 has_rasterizer_discard_enable = true;
2188 }
2189 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2190 if (has_depth_bias_enable) {
2191 skip |= LogError(
2192 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2193 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002194 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002195 i);
2196 }
2197 has_depth_bias_enable = true;
2198 }
2199 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2200 if (has_logic_op) {
2201 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2202 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002203 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002204 i);
2205 }
2206 has_logic_op = true;
2207 }
2208 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2209 if (has_primitive_restart_enable) {
2210 skip |= LogError(
2211 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2212 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002213 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002214 i);
2215 }
2216 has_primitive_restart_enable = true;
2217 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002218 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2219 if (has_dynamic_vertex_input) {
2220 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002221 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2222 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2223 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002224 }
2225 has_dynamic_vertex_input = true;
2226 }
Petr Kraus299ba622017-11-24 03:09:03 +01002227 }
2228 }
2229
sfricke-samsung3b944422021-01-23 02:15:19 -08002230 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2231 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2232 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002233 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2234 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002235 i);
2236 }
2237
2238 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2239 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2240 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002241 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002242 i);
2243 }
2244
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002245 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2246 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002247 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002248 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2249 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2250 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002251 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002252 }
2253
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002254 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002255
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002256 // Collect active stages and other information
2257 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002258 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002259 bool has_eval = false;
2260 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002261 if (create_info.pStages != nullptr) {
2262 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2263 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002264
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002265 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002266 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002267 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002268 has_eval = true;
2269 }
2270
Tony-LunarGd29cc032022-05-13 14:38:27 -06002271 skip |= validate_required_pointer(
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002272 "vkCreateGraphicsPipelines",
Tony-LunarGd29cc032022-05-13 14:38:27 -06002273 ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}),
2274 create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter");
2275
2276 if (create_info.pStages[stage_index].pName) {
2277 skip |= validate_string(
2278 "vkCreateGraphicsPipelines",
2279 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2280 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
2281 }
ziga-lunargc6341372021-07-28 12:57:42 +02002282
2283 std::stringstream msg;
2284 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2285 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002286 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002287 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002288 }
2289
2290 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002291 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2292 skip |=
2293 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2294 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2295 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2296 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002297
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002298 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002299 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2300
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002301 skip |= validate_struct_pnext(
2302 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002303 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002304 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2305 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2306 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2307 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002308
2309 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002310 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002311 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2312 }
2313
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002314 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002315 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2316 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002317 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002318 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2319 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2320
2321 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002322 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002323 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002324
2325 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002326 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002327 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2328
2329 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2330 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002331 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002332 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2333
2334 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002335 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002336 }
2337
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002338 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2339 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002340
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002341 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002342 skip |=
2343 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2344 "vkCreateGraphicsPipelines: pararameter "
2345 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2346 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002347 }
2348
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002349 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002350 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002351 skip |=
2352 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2353 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2354 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2355 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2356 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002357 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2358 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002359 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002360 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2361 skip |=
2362 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2363 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002364 create_info.pVertexInputState->vertexBindingDescriptionCount,
2365 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002366 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2367
2368 skip |= validate_array(
2369 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2370 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2371 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2372 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2373
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002374 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002375 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002376 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002377 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002378 skip |= validate_ranged_enum(
2379 "vkCreateGraphicsPipelines",
2380 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2381 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002382 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002383 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2384 }
2385 }
2386
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002387 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002388 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002389 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002390 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002391 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002392 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002393 skip |= validate_ranged_enum(
2394 "vkCreateGraphicsPipelines",
2395 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2396 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002397 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002398 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002399 if (FormatIsDepthOrStencil(format)) {
2400 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2401 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2402 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2403 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002404 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2405 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002406 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2407 "alignment, replace with a color format.",
2408 i, vertex_attribute_description_index, string_VkFormat(format));
2409 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002410 }
2411 }
2412
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002413 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002414 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2415 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002416 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2417 ") is "
2418 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002420 }
2421
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002422 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002423 skip |=
2424 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2425 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002426 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2427 ") is "
2428 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002429 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002430 }
2431
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002432 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002433 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2434 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002435 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2436 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002437 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2438 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002439 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2440 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002441 "(%" PRIu32 ") is not distinct.",
2442 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002443 }
2444 vertex_bindings.insert(vertex_bind_desc.binding);
2445
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002446 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002447 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2448 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002449 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2450 "].binding (%" PRIu32
2451 ") is "
2452 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002453 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002454 }
2455
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002456 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002457 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2458 "vkCreateGraphicsPipelines: parameter "
2459 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2460 "].stride (%" PRIu32
2461 ") is greater "
2462 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2463 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 }
2465 }
2466
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002467 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002468 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2469 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002470 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2471 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002472 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2473 "vkCreateGraphicsPipelines: parameter "
2474 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2475 "].location (%" PRIu32 ") is not distinct.",
2476 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002477 }
2478 attribute_locations.insert(vertex_attrib_desc.location);
2479
2480 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2481 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002482 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2483 "vkCreateGraphicsPipelines: parameter "
2484 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2485 "].binding (%" PRIu32
2486 ") does not exist "
2487 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2488 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002489 }
2490
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002491 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002492 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2493 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002494 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2495 "].location (%" PRIu32
2496 ") is "
2497 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002498 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002499 }
2500
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002501 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002502 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2503 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002504 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2505 "].binding (%" PRIu32
2506 ") is "
2507 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509 }
2510
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002511 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002512 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2513 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002514 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2515 "].offset (%" PRIu32
2516 ") is "
2517 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002518 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002519 }
2520 }
2521 }
2522
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002523 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2524 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002525 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002526 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002527 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2528 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002529 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002530 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002531 i, i);
2532 } else {
2533 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2534 skip |= validate_struct_pnext(
2535 "vkCreateGraphicsPipelines",
2536 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002537 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002538 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2539 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002540
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002541 skip |= validate_reserved_flags(
2542 "vkCreateGraphicsPipelines",
2543 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002544 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002545
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002546 if (create_info.pTessellationState->patchControlPoints == 0 ||
2547 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2548 skip |=
2549 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2550 "vkCreateGraphicsPipelines: invalid parameter "
2551 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2552 ". patchControlPoints "
2553 "should be >0 and <=%" PRIu32 ".",
2554 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002555 }
2556 }
2557 }
2558
2559 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002560 if ((create_info.pRasterizationState != nullptr) &&
2561 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2562 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2564 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2565 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2566 "].pViewportState (=NULL) is not a valid pointer.",
2567 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002569 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002570
2571 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002572 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2573 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2574 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2575 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002576 }
2577
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002578 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002579 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002580 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2581 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002582 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2583 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002584 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002585 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002587 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002588 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002589 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002590 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002591 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002592 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002593 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002594 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002595 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596
2597 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002598 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002600 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002601
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002602 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002603 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002604 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002605 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002606 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002607 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2608 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002609 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002610 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2611 const auto depth_clip_control_struct =
2612 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002613
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002615 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002616 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2617 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2618 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2619 ") is not 1.",
2620 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002621 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002623 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002624 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2625 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2626 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2627 ") is not 1.",
2628 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002630
Dave Houlton142c4cb2018-10-17 15:04:41 -06002631 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2632 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002633 skip |= LogError(
2634 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2635 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2636 "disabled, but pCreateInfos[%" PRIu32
2637 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2638 ") is not 1.",
2639 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002640 }
2641
Jeff Bolz9af91c52018-09-01 21:53:57 -05002642 if (shading_rate_image_struct &&
2643 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002644 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2645 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2646 "disabled, but pCreateInfos[%" PRIu32
2647 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2648 ") is neither 0 nor 1.",
2649 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002650 }
2651
Petr Krausa6103552017-11-16 21:21:58 +01002652 } else { // multiViewport enabled
2653 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002654 if (!has_dynamic_viewport_with_count) {
2655 skip |= LogError(
2656 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2657 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2658 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002659 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002660 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2661 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2662 "].pViewportState->viewportCount (=%" PRIu32
2663 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2664 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002665 } else if (has_dynamic_viewport_with_count) {
2666 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2667 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2668 "].pViewportState->viewportCount (=%" PRIu32
2669 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2670 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002671 }
Petr Krausa6103552017-11-16 21:21:58 +01002672
2673 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002674 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002675 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2676 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2677 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002678 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002679 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002680 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2681 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002682 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002683 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2684 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2685 "].pViewportState->scissorCount (=%" PRIu32
2686 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2687 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002688 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002689 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2690 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2691 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2692 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002693 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2694 "].pViewportState->scissorCount (=%" PRIu32
2695 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2696 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002697 }
2698 }
2699
ziga-lunarg845883b2021-07-14 15:05:00 +02002700 if (!has_dynamic_scissor && viewport_state.pScissors) {
2701 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2702 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002703
2704 if (scissor.offset.x < 0) {
2705 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2706 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2707 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2708 scissor.offset.x, i, scissor_i);
2709 }
2710
2711 if (scissor.offset.y < 0) {
2712 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2713 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2714 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2715 scissor.offset.y, i, scissor_i);
2716 }
2717
ziga-lunarg845883b2021-07-14 15:05:00 +02002718 const int64_t x_sum =
2719 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2720 if (x_sum > std::numeric_limits<int32_t>::max()) {
2721 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2722 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2723 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2724 "] will overflow int32_t.",
2725 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2726 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002727
ziga-lunarg845883b2021-07-14 15:05:00 +02002728 const int64_t y_sum =
2729 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2730 if (y_sum > std::numeric_limits<int32_t>::max()) {
2731 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2732 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2733 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2734 "] will overflow int32_t.",
2735 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2736 }
2737 }
2738 }
2739
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002740 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002741 skip |=
2742 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2743 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2744 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2745 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002746 }
2747
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002748 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002749 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2750 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2751 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2752 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2753 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002754 }
2755
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002756 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2757 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2758 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2759 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2760 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2761 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2762 skip |= LogError(
2763 device, vuid,
2764 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2765 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2766 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2767 }
Petr Krausa6103552017-11-16 21:21:58 +01002768 }
2769
Dave Houlton142c4cb2018-10-17 15:04:41 -06002770 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002771 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002772 skip |=
2773 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2774 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2775 ") must be zero or identical to pCreateInfos[%" PRIu32
2776 "].pViewportState->viewportCount (=%" PRIu32 ").",
2777 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002778 }
2779
Dave Houlton142c4cb2018-10-17 15:04:41 -06002780 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002781 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 skip |= LogError(
2783 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002784 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2785 "] "
2786 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2787 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2788 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002789 }
2790
Petr Krausa6103552017-11-16 21:21:58 +01002791 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002792 skip |= LogError(
2793 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002794 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2795 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002796 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2797 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002798 }
2799
2800 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002801 skip |= LogError(
2802 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002803 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2804 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002805 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2806 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002807 }
2808
Jeff Bolz3e71f782018-08-29 23:15:45 -05002809 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002810 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2811 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2812 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002813 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002814 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2815 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2816 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2817 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002818 }
2819
Jeff Bolz9af91c52018-09-01 21:53:57 -05002820 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002821 shading_rate_image_struct->viewportCount > 0 &&
2822 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002823 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002824 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002825 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002826 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2827 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002828 i, i);
2829 }
2830
Chris Mayer328d8212018-12-11 14:16:18 +01002831 if (vp_swizzle_struct) {
2832 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002833 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2834 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2835 " does "
2836 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2837 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002838 }
2839 }
2840
Petr Krausb3fcdb42018-01-09 22:09:09 +01002841 // validate the VkViewports
2842 if (!has_dynamic_viewport && viewport_state.pViewports) {
2843 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2844 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002845 const char *fn_name = "vkCreateGraphicsPipelines";
2846 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2847 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2848 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002849 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002850 }
2851 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002852
sfricke-samsung45996a42021-09-16 13:45:27 -07002853 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002854 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2855 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2856 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2857 "VK_NV_clip_space_w_scaling extension is not enabled.",
2858 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002859 }
2860
sfricke-samsung45996a42021-09-16 13:45:27 -07002861 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002862 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2863 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2864 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2865 "VK_EXT_discard_rectangles extension is not enabled.",
2866 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002867 }
2868
sfricke-samsung45996a42021-09-16 13:45:27 -07002869 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002870 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2871 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2872 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2873 "VK_EXT_sample_locations extension is not enabled.",
2874 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002875 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002876
sfricke-samsung45996a42021-09-16 13:45:27 -07002877 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002878 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2879 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2880 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2881 "VK_NV_scissor_exclusive extension is not enabled.",
2882 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002883 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002884
2885 if (coarse_sample_order_struct &&
2886 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2887 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002888 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2889 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2890 "] "
2891 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2892 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2893 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002894 }
2895
2896 if (coarse_sample_order_struct) {
2897 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002898 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002899 }
2900 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002901
2902 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2903 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002904 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2905 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2906 "] "
2907 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2908 ") "
2909 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2910 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002911 }
2912 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002913 skip |= LogError(
2914 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002915 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2916 "] "
2917 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2918 i);
2919 }
2920 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002921
2922 if (depth_clip_control_struct) {
2923 const auto *depth_clip_control_features =
2924 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2925 const bool enabled_depth_clip_control =
2926 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2927 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2928 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2929 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2930 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2931 "depthClipControl feature is not enabled. ",
2932 i);
2933 }
2934 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935 }
2936
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002937 const bool is_frag_out_graphics_lib =
2938 graphics_lib_info &&
2939 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002940 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002941 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002942 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2943 "].pRasterizationState->rasterizerDiscardEnable "
2944 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002945 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002946 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002947 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002948 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002949 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2950 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002951 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002952 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002953 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002955 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002956 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002957 skip |= validate_struct_pnext(
2958 "vkCreateGraphicsPipelines",
2959 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002960 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002961 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2962 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002963
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002964 skip |= validate_reserved_flags(
2965 "vkCreateGraphicsPipelines",
2966 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002967 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002969 skip |= validate_bool32(
2970 "vkCreateGraphicsPipelines",
2971 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002972 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002974 skip |= validate_array(
2975 "vkCreateGraphicsPipelines",
2976 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2977 ParameterName::IndexVector{i}),
2978 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002979 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2980 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002981
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002982 skip |= validate_flags("vkCreateGraphicsPipelines",
2983 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2984 ParameterName::IndexVector{i}),
2985 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002986 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002987 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002988
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002989 skip |= validate_bool32("vkCreateGraphicsPipelines",
2990 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2991 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002992 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002993
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002994 skip |= validate_bool32(
2995 "vkCreateGraphicsPipelines",
2996 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002997 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002998
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002999 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003000 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
3001 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3002 "].pMultisampleState->sType must be "
3003 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003004 i);
John Zulauf7acac592017-11-06 11:15:53 -07003005 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003006 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003007 if (!physical_device_features.sampleRateShading) {
3008 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
3009 "vkCreateGraphicsPipelines(): parameter "
3010 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
3011 i);
3012 }
3013 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
3014 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003015 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003016 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003017
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003018 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
3019 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
3020 "].pMultisampleState->minSampleShading.",
3021 i);
3022 }
John Zulauf7acac592017-11-06 11:15:53 -07003023 }
3024 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003025
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003026 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003027 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003028
3029 if (line_state) {
3030 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
3031 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003032 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003033 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003034 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3035 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003036 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003037 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003038 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003039 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003040 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003041 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3042 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003043 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003044 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003045 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003046 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003047 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003048 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3049 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003050 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003051 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003052 }
3053 }
3054 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3055 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3056 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003057 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003058 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3059 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003060 "range [1,256].",
3061 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003062 }
3063 }
3064 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003065 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003066 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3067 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003068 skip |=
3069 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003070 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3071 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003072 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3073 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003074 }
3075 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3076 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003077 skip |=
3078 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003079 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3080 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003081 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3082 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003083 }
3084 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3085 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003086 skip |=
3087 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003088 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3089 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003090 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3091 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003092 }
3093 if (line_state->stippledLineEnable) {
3094 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3095 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003096 skip |=
3097 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003098 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3099 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003100 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3101 "stippledRectangularLines feature.",
3102 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003103 }
3104 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3105 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003106 skip |=
3107 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003108 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3109 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003110 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3111 "stippledBresenhamLines feature.",
3112 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003113 }
3114 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3115 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003116 skip |=
3117 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003118 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3119 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003120 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3121 "stippledSmoothLines feature.",
3122 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003123 }
3124 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003125 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003126 skip |=
3127 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003128 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3129 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003130 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3131 "stippledRectangularLines and strictLines features.",
3132 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003133 }
3134 }
3135 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003136 }
3137
Petr Krause91f7a12017-12-14 20:57:36 +01003138 bool uses_color_attachment = false;
3139 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003140 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003141 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003142 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003143 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003144 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003145 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003146 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003147 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003148 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003149 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003150 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003151 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003152 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003153 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003154 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003155 }
3156
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003157 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003159 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003161 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003162 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163
Mike Schuchardt00e81452021-11-29 11:11:20 -08003164 skip |=
3165 validate_flags("vkCreateGraphicsPipelines",
3166 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3167 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003168 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003169 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170
3171 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003172 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003174 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003175
3176 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003177 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003178 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003179 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003180
3181 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003182 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003184 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003185 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003186
3187 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003188 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003189 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003190 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191
3192 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003193 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003194 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003195 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003196
3197 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003198 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003199 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003200 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003201 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003202
3203 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003204 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003205 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003206 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003207 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003208
3209 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003210 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003211 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003212 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003213 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003214
3215 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003216 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003218 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003219 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003220
3221 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003222 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003223 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003224 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003225 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003226
3227 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003228 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003229 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003230 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003231 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003232
3233 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003234 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003235 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003236 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003237 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003238
3239 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003240 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003241 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003242 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003243 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003244
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003245 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003246 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003247 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3248 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003249 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3250 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003251 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003252
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003253 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003254 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3255 const auto *rasterization_order_attachment_access_feature =
3256 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3257 const bool rasterization_order_depth_attachment_access_feature_enabled =
3258 rasterization_order_attachment_access_feature &&
3259 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3260 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3261 skip |= LogError(
3262 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3263 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3264 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3265 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003266 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003267 }
3268
3269 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3270 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003271 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003272 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3273 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003274 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003275 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3276 }
3277 }
3278
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003279 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003280 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3281 const auto *rasterization_order_attachment_access_feature =
3282 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3283 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3284 rasterization_order_attachment_access_feature &&
3285 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3286 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3287 skip |= LogError(
3288 device,
3289 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3290 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3291 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3292 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003293 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003294 }
3295
3296 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3297 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003298 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003299 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3300 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003301 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003302 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3303 }
3304 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003305 }
3306
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003307 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003308 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3309 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003310
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003311 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3312 skip |=
3313 validate_struct_type("vkCreateGraphicsPipelines",
3314 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3315 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3316 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3317 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003318
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003320 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003321 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003322 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3323 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003324 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003325 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3326 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003327
Mike Schuchardt00e81452021-11-29 11:11:20 -08003328 skip |= validate_flags("vkCreateGraphicsPipelines",
3329 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3330 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003331 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003332 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003334 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003335 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3336 const auto *rasterization_order_attachment_access_feature =
3337 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3338 const bool rasterization_order_color_attachment_access_feature_enabled =
3339 rasterization_order_attachment_access_feature &&
3340 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3341
3342 if (!rasterization_order_color_attachment_access_feature_enabled) {
3343 skip |= LogError(
3344 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3345 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3346 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3347 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003348 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003349 }
3350
3351 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003352 skip |=
3353 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3354 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3355 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3356 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3357 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003358 }
3359 }
3360
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003361 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003362 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003363 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003364 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003365
3366 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003367 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003368 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3369 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003370 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3371 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003372
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003373 if (create_info.pColorBlendState->pAttachments != NULL) {
3374 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003375 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003376 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003377 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003378 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003379 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003380
3381 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003382 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003383 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003384 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003385 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003386 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003387 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003388
3389 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003390 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003391 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003392 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003393 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003394 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003395 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003396
3397 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003398 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003399 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003400 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003401 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003402 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003403 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003404
3405 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003406 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003407 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003408 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003409 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003410 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003411 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412
3413 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003414 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003415 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003416 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003417 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003418 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003419 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003420
3421 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003422 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003423 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003424 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003425 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003426 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003427 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003428
3429 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003430 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003431 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003432 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003434 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003435 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003436
3437 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3438 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003439 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003440 case VK_BLEND_OP_ZERO_EXT:
3441 case VK_BLEND_OP_SRC_EXT:
3442 case VK_BLEND_OP_DST_EXT:
3443 case VK_BLEND_OP_SRC_OVER_EXT:
3444 case VK_BLEND_OP_DST_OVER_EXT:
3445 case VK_BLEND_OP_SRC_IN_EXT:
3446 case VK_BLEND_OP_DST_IN_EXT:
3447 case VK_BLEND_OP_SRC_OUT_EXT:
3448 case VK_BLEND_OP_DST_OUT_EXT:
3449 case VK_BLEND_OP_SRC_ATOP_EXT:
3450 case VK_BLEND_OP_DST_ATOP_EXT:
3451 case VK_BLEND_OP_XOR_EXT:
3452 case VK_BLEND_OP_INVERT_EXT:
3453 case VK_BLEND_OP_INVERT_RGB_EXT:
3454 case VK_BLEND_OP_LINEARDODGE_EXT:
3455 case VK_BLEND_OP_LINEARBURN_EXT:
3456 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3457 case VK_BLEND_OP_LINEARLIGHT_EXT:
3458 case VK_BLEND_OP_PINLIGHT_EXT:
3459 case VK_BLEND_OP_HARDMIX_EXT:
3460 case VK_BLEND_OP_PLUS_EXT:
3461 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3462 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3463 case VK_BLEND_OP_PLUS_DARKER_EXT:
3464 case VK_BLEND_OP_MINUS_EXT:
3465 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3466 case VK_BLEND_OP_CONTRAST_EXT:
3467 case VK_BLEND_OP_INVERT_OVG_EXT:
3468 case VK_BLEND_OP_RED_EXT:
3469 case VK_BLEND_OP_GREEN_EXT:
3470 case VK_BLEND_OP_BLUE_EXT:
3471 invalid = true;
3472 break;
3473 default:
3474 break;
3475 }
3476 if (invalid) {
3477 skip |= LogError(
3478 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3479 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3480 "].pColorBlendState->pAttachments[%" PRIu32
3481 "].colorBlendOp (%s) is not valid when "
3482 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3483 "VK_FALSE",
3484 i, attachment_index,
3485 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003486 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003487 }
3488 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003489 }
3490 }
3491
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003492 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003493 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003494 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3495 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003496 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3497 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003498 }
3499
3500 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003501 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003502 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003503 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003504 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003505 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003506 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003507 }
3508 }
3509 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003510
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003511 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003512 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003513 if (create_info.basePipelineIndex != -1) {
3514 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003515 skip |=
3516 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003517 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3518 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003519 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003520 "and pCreateInfos->basePipelineIndex is not -1.",
3521 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003522 }
3523 }
3524
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003525 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3526 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003527 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003528 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3529 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003530 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003531 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3532 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003533 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003534 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003535 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003536 skip |=
3537 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003538 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3539 ") must be a valid"
3540 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003541 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003542 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003543 }
3544 }
3545
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003546 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003547 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003548 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003549 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003550 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3551 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3552 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3553 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003554 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003555 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003556 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003557 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003558 "pCreateInfos[%" PRIu32
3559 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003560 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3561 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003562 }
3563 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003564 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3565 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003566 (physical_device_features.fillModeNonSolid == false)) {
3567 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003568 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3569 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003570 "pCreateInfos[%" PRIu32
3571 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003572 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3573 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003574 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003575 }
Petr Kraus299ba622017-11-24 03:09:03 +01003576
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003577 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003578 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003579 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3580 "The line width state is static (pCreateInfos[%" PRIu32
3581 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3582 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3583 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003584 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003585 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003586 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003587
3588 // Validate no flags not allowed are used
3589 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003590 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003591 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3592 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003593 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3594 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003595 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003596 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3597 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003598 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003599 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3600 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003601 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3602 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003603 }
3604 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3605 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003606 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3607 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003608 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3609 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003610 }
3611 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3612 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003613 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3614 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003615 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3616 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003617 }
3618 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3619 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003620 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3621 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003622 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3623 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003624 }
3625 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3626 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003627 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3628 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003629 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3630 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003631 }
3632 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3633 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003634 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3635 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003636 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3637 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003638 }
3639 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3640 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003641 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3642 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003643 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3644 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003645 }
3646 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3647 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003648 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3649 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003650 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3651 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003652 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003653 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3654 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3655 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3656 "]->flags (0x%x) must not include "
3657 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3658 i, flags);
3659 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003660 }
3661 }
3662
3663 return skip;
3664}
3665
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003666bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3667 uint32_t createInfoCount,
3668 const VkComputePipelineCreateInfo *pCreateInfos,
3669 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003670 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003671 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003672 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003673 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003674 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003675 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003676 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003677 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3678 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003679 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003680 skip |= LogError(
3681 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3682 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3683 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3684 feedback_count, i);
3685 }
Peter Chen85366392019-05-14 15:20:11 -04003686 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003687
3688 // Make sure compute stage is selected
3689 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003690 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003691 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3692 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003693 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003694 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003695
sfricke-samsungeb549012021-04-16 01:25:51 -07003696 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3697 // Validate no flags not allowed are used
3698 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003699 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3700 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3701 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3702 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003703 }
3704 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3705 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003706 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3707 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003708 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3709 i, flags);
3710 }
3711 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3712 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003713 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3714 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003715 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3716 i, flags);
3717 }
3718 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3719 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003720 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3721 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003722 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3723 i, flags);
3724 }
3725 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3726 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003727 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3728 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003729 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3730 i, flags);
3731 }
3732 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3733 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003734 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3735 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003736 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3737 i, flags);
3738 }
3739 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3740 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003741 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3742 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003743 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3744 i, flags);
3745 }
3746 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3747 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003748 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3749 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003750 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3751 i, flags);
3752 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003753 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3754 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003755 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3756 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003757 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3758 i, flags);
3759 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003760 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3761 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003762 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3763 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003764 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3765 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003766 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003767 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3768 if (pCreateInfos[i].basePipelineIndex != -1) {
3769 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3770 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3771 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3772 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3773 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3774 i);
3775 }
3776 }
3777
3778 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3779 if (pCreateInfos[i].basePipelineIndex != -1) {
3780 skip |= LogError(
3781 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3782 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3783 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3784 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3785 i);
3786 }
3787 } else {
3788 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3789 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3790 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3791 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3792 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3793 }
3794 }
3795 }
ziga-lunargc6341372021-07-28 12:57:42 +02003796
3797 std::stringstream msg;
3798 msg << "pCreateInfos[%" << i << "].stage";
3799 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003800 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003801 return skip;
3802}
3803
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003804bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003805 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003806 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003807
3808 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003809 const auto &features = physical_device_features;
3810 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003811
John Zulauf71968502017-10-26 13:51:15 -06003812 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3813 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003814 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3815 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3816 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3817 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003818 }
3819
3820 // Anistropy cannot be enabled in sampler unless enabled as a feature
3821 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003822 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3823 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3824 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003825 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003826 }
John Zulauf71968502017-10-26 13:51:15 -06003827
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003828 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3829 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003830 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3831 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3832 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3833 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003834 }
3835 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003836 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3837 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3838 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3839 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003840 }
3841 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003842 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3843 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3844 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3845 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003846 }
3847 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3848 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3849 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3850 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003851 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3852 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3853 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3854 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3855 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3856 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003857 }
3858 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003859 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3860 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3861 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003862 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003863 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003864 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3865 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3866 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003867 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003868 }
3869
3870 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003871 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003872 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003873 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3874 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003875 if (sampler_reduction != nullptr) {
3876 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003877 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3878 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
3879 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003880 }
3881 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003882 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003883 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003884 if (!IsExtEnabled(device_extensions.vk_ext_sampler_filter_minmax)) {
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003885 skip |= LogError(device, "VUID-VkSamplerCreateInfo-pNext-06726",
sjfricke751b7092022-04-12 21:49:37 +09003886 "vkCreateSampler(): sampler reduction mode is %s, but extension %s is not enabled.",
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003887 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3888 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
3889 }
ziga-lunarg01be97a2022-05-01 14:30:39 +02003890
3891 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
3892 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
3893 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
3894 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
3895 "extension %s is not enabled.",
3896 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3897 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
3898 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
3899 }
3900 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003901 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003902
3903 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3904 // valid VkBorderColor value
3905 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3906 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3907 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003908 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3909 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003910 }
3911
John Zulauf275805c2017-10-26 15:34:49 -06003912 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003913 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003914 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3915 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003916 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3917 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3918 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003919 }
3920 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003921
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003922 // Check for valid Lod range
3923 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003924 skip |=
3925 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3926 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003927 }
3928
3929 // Check mipLodBias to device limit
3930 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003931 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3932 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3933 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003934 }
3935
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003936 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003937 if (sampler_conversion != nullptr) {
3938 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3939 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3940 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3941 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003942 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003943 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003944 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3945 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3946 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3947 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3948 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3949 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3950 }
3951 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003952
3953 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3954 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3955 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3956 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3957 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3958 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3959 }
3960 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3961 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3962 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3963 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3964 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3965 }
3966 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3967 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3968 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3969 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3970 pCreateInfo->minLod, pCreateInfo->maxLod);
3971 }
3972 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3973 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3974 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3975 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3976 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3977 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3978 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3979 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3980 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3981 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3982 }
3983 if (pCreateInfo->anisotropyEnable) {
3984 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3985 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3986 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3987 }
3988 if (pCreateInfo->compareEnable) {
3989 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3990 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3991 "pCreateInfo->compareEnable must be VK_FALSE");
3992 }
3993 if (pCreateInfo->unnormalizedCoordinates) {
3994 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3995 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3996 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3997 }
3998 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003999
Piers Daniell833b9492021-11-20 11:47:10 -07004000 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
4001 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
4002 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
4003 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4004 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
4005 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
4006 }
4007 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
4008 if (!custom_create_info) {
4009 skip |= LogError(
4010 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
4011 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
4012 "struct in pNext chain.\n",
4013 string_VkBorderColor(pCreateInfo->borderColor));
4014 } else {
4015 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
4016 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
4017 !FormatIsSampledInt(custom_create_info->format)) ||
4018 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
4019 !FormatIsSampledFloat(custom_create_info->format)))) {
4020 skip |=
4021 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06004022 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
4023 "whose type does not match\n",
4024 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07004025 ;
4026 }
4027 }
4028 }
4029
4030 const auto *border_color_component_mapping =
4031 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
4032 if (border_color_component_mapping) {
4033 const auto *border_color_swizzle_features =
4034 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4035 bool border_color_swizzle_features_enabled =
4036 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4037 if (!border_color_swizzle_features_enabled) {
4038 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4039 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4040 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004041 }
4042 }
4043 }
4044
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004045 return skip;
4046}
4047
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004048bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
4049 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4050 const char *func_name) const {
4051 bool skip = false;
4052
4053 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4054 uint32_t mutable_type_count = 0;
4055 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4056 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4057 }
4058 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4059 if (mutable_type_count == 0) {
4060 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4061 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4062 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4063 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4064 "].descriptorTypeCount is 0.",
4065 func_name, i, i);
4066 }
4067 } else {
4068 if (mutable_type_count > 0) {
4069 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4070 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4071 "].descriptorType is %s, but "
4072 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4073 "].descriptorTypeCount is not 0.",
4074 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4075 }
4076 }
4077 }
4078
4079 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4080 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4081 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
4082 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4083 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4084 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4085 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4086 func_name, j, k);
4087 break;
4088 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4089 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4090 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4091 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4092 func_name, j, k);
4093 break;
4094 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4095 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4096 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4097 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4098 func_name, j, k);
4099 break;
4100 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4101 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4102 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4103 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4104 func_name, j, k);
4105 break;
4106 default:
4107 break;
4108 }
4109 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4110 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4111 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4112 skip |=
4113 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4114 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4115 "].pDescriptorTypes[%" PRIu32
4116 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4117 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4118 func_name, j, k, j, l,
4119 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4120 }
4121 }
4122 }
4123 }
4124
4125 return skip;
4126}
4127
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004128bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4129 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4130 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004131 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004132 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004133
ziga-lunargfc6896f2021-10-15 18:46:12 +02004134 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4135 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4136 bool mutable_descriptor_type_features_enabled =
4137 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4138
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004139 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4140 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4141 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4142 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004143 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4144 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4145 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4146 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4147 ++descriptor_index) {
4148 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004149 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004150 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004151 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4152 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004153 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004154 }
4155 }
4156 }
4157
4158 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4159 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4160 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004161 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004162 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4163 "].descriptorCount is not 0, "
4164 "pCreateInfo->pBindings[%" PRIu32
4165 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 "values.",
4167 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004168 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004169
4170 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4171 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4172 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004173 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4174 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4175 "].descriptorCount is not 0 and "
4176 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4177 "].stageFlags "
4178 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4179 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004180 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004181
4182 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4183 if (!mutable_descriptor_type) {
4184 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4185 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4186 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4187 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4188 i);
4189 }
4190 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4191 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4192 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4193 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4194 "pImmutableSamplers is not NULL.",
4195 i);
4196 }
4197 if (!mutable_descriptor_type_features_enabled) {
4198 skip |= LogError(
4199 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4200 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4201 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4202 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4203 i);
4204 }
4205 }
4206
4207 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4208 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4209 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4210 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4211 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4212 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4213 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004214 }
4215 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004216
4217 if (mutable_descriptor_type) {
4218 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4219 "vkDescriptorSetLayoutCreateInfo");
4220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004221 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004222 if (pCreateInfo) {
4223 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4224 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4225 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4226 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4227 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4228 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4229 }
4230 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4231 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4232 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4233 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4234 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4235 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4236 }
4237 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4238 !mutable_descriptor_type_features_enabled) {
4239 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4240 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4241 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4242 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4243 }
4244 }
4245
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004246 return skip;
4247}
4248
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004249bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4250 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004251 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004252 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4253 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4254 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004255 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4256 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004257}
4258
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004259bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4260 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004261 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004262 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004263
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004264 if (pDescriptorWrites != NULL) {
4265 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4266 // descriptorCount must be greater than 0
4267 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004268 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4269 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4270 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004271 }
4272
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004273 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004274 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004275 // dstSet must be a valid VkDescriptorSet handle
4276 skip |= validate_required_handle(vkCallingFunction,
4277 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4278 pDescriptorWrites[i].dstSet);
4279 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004280
4281 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4282 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4283 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4284 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4285 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004286 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004287 if (!isPushDescriptor) {
4288 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4289 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4290 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4291 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4292 // ObjectLifetimes::ValidateDescriptorWrite.
4293 skip |= LogError(
4294 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4295 "%s(): if pDescriptorWrites[%" PRIu32
4296 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4297 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4298 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4299 vkCallingFunction, i, i);
4300 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4301 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4302 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4303 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4304 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4305 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4306 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4307 "%s(): if pDescriptorWrites[%" PRIu32
4308 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4309 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4310 "].pImageInfo must not be NULL.",
4311 vkCallingFunction, i, i);
4312 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004313 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4314 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004315 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4316 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004317 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4318 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004319 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004320 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4321 ParameterName::IndexVector{i, descriptor_index}),
4322 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004323 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004324 }
4325 }
4326 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4327 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4328 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4329 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4330 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4331 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4332 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004333 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004334 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004335 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004336 "%s(): if pDescriptorWrites[%" PRIu32
4337 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004338 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4339 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004340 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004341 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004342 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004343 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004344 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004345 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004346 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4347 ++descriptor_index) {
4348 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4349 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4350 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004351 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004352 "%s(): if pDescriptorWrites[%" PRIu32
4353 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004354 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004355 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4356 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004357 }
4358 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004359 }
4360 }
4361 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4362 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004363 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004364 }
4365
4366 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4367 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004368 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004369 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4370 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004371 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004372 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004373 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004374 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004375 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004376 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004377 }
4378 }
4379 }
4380 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4381 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004382 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004383 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4384 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004385 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004386 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004387 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004388 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004389 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004390 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004391 }
4392 }
4393 }
4394 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004395 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4396 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004397 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004398 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004399 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4400 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4401 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4402 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004403 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004404 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4405 pDescriptorWrites[i].descriptorCount);
4406 }
4407 // further checks only if we have right structtype
4408 if (pnext_struct) {
4409 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4410 skip |= LogError(
4411 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004412 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4413 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004414 ".",
4415 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004416 }
sourav parmarbcee7512020-12-28 14:34:49 -08004417 if (pnext_struct->accelerationStructureCount == 0) {
4418 skip |= LogError(device,
4419 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004420 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004421 }
4422 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004423 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004424 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4425 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4426 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4427 skip |= LogError(device,
4428 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4429 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004430 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004431 }
4432 }
4433 }
sourav parmarbcee7512020-12-28 14:34:49 -08004434 }
4435 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004436 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004437 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4438 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4439 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4440 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004441 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004442 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4443 pDescriptorWrites[i].descriptorCount);
4444 }
4445 // further checks only if we have right structtype
4446 if (pnext_struct) {
4447 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4448 skip |= LogError(
4449 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004450 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4451 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004452 ".",
4453 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004454 }
sourav parmarbcee7512020-12-28 14:34:49 -08004455 if (pnext_struct->accelerationStructureCount == 0) {
4456 skip |= LogError(device,
4457 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004458 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004459 }
4460 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004461 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004462 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4463 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4464 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4465 skip |= LogError(device,
4466 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4467 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004468 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004469 }
4470 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004471 }
4472 }
4473 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004474 }
4475 }
4476 return skip;
4477}
4478
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004479bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4480 const VkWriteDescriptorSet *pDescriptorWrites,
4481 uint32_t descriptorCopyCount,
4482 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004483 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004484}
4485
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004486bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004487 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004488 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004489 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4490}
4491
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004492bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4493 const VkAllocationCallbacks *pAllocator,
4494 VkRenderPass *pRenderPass) const {
4495 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4496}
4497
Mike Schuchardt2df08912020-12-15 16:28:09 -08004498bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004499 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004500 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004501 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4502}
4503
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004504bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4505 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004506 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004507 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004508
4509 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4510 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4511 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004512 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4513 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004514 return skip;
4515}
4516
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004517bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004518 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004519 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004520
4521 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4522 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004523 bool cb_is_secondary;
4524 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004525 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004526 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4527 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004528
Tony-LunarG3c287f62020-12-17 12:39:49 -07004529 if (cb_is_secondary) {
4530 // Implicit VUs
4531 // validate only sType here; pointer has to be validated in core_validation
4532 const bool k_not_required = false;
4533 const char *k_no_vuid = nullptr;
4534 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4535 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004536 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4537 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004538
Tony-LunarG3c287f62020-12-17 12:39:49 -07004539 if (info) {
4540 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004541 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004542 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4543 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004544 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004545 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004546 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4547 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4548 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4549 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004550
Tony-LunarG3c287f62020-12-17 12:39:49 -07004551 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004552
Tony-LunarG3c287f62020-12-17 12:39:49 -07004553 // Explicit VUs
4554 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004555 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004556 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4557 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4558 cmd_name);
4559 }
4560
4561 if (physical_device_features.inheritedQueries) {
4562 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004563 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4564 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4565 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004566 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004567 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004568 }
4569
4570 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004571 skip |=
4572 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4573 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4574 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4575 } else { // !pipelineStatisticsQuery
4576 skip |=
4577 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4578 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004579 }
4580
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004581 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004582 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004583 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004584 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4585 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4586 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004587 commandBuffer,
4588 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004589 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4590 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4591 }
Petr Kraus139757b2019-08-15 17:19:33 +02004592 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004593
4594 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4595 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4596 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4597 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4598 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4599 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4600 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4601 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4602 }
Petr Kraus139757b2019-08-15 17:19:33 +02004603 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004604 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004605 return skip;
4606}
4607
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004608bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004609 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004610 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004611
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004612 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004613 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004614 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4615 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4616 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004617 }
4618 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004619 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4620 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4621 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004622 }
4623 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004624 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004625 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004626 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4627 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4628 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4629 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004630 }
4631 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004632
4633 if (pViewports) {
4634 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4635 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004636 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004637 skip |= manual_PreCallValidateViewport(
4638 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004639 }
4640 }
4641
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004642 return skip;
4643}
4644
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004645bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004646 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004647 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004648
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004649 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004650 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004651 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4652 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4653 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004654 }
4655 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004656 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4657 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4658 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004659 }
4660 } else { // multiViewport enabled
4661 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004662 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004663 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4664 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4665 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4666 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004667 }
4668 }
4669
Petr Kraus6260f0a2018-02-27 21:15:55 +01004670 if (pScissors) {
4671 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4672 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004673
Petr Kraus6260f0a2018-02-27 21:15:55 +01004674 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004675 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4676 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4677 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004678 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004679
Petr Kraus6260f0a2018-02-27 21:15:55 +01004680 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004681 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4682 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4683 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004684 }
4685
4686 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4687 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004688 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4689 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4690 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4691 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004692 }
4693
4694 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4695 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004696 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4697 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4698 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4699 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004700 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004701 }
4702 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004703
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004704 return skip;
4705}
4706
Jeff Bolz5c801d12019-10-09 10:38:45 -05004707bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004708 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004709
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004710 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004711 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4712 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004713 }
4714
4715 return skip;
4716}
4717
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004718bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004719 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004720 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004721
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004722 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004723 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004724 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4725 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004726 }
4727 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004728 skip |=
4729 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4730 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4731 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004732 }
4733 return skip;
4734}
4735
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004736bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004737 VkDeviceSize offset, uint32_t drawCount,
4738 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004739 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004740 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004741 skip |=
4742 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4743 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4744 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004745 }
4746 if (drawCount > device_limits.maxDrawIndirectCount) {
4747 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004748 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4749 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004750 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004751 }
4752 return skip;
4753}
4754
sfricke-samsungf692b972020-05-02 08:00:45 -07004755bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4756 VkDeviceSize countBufferOffset, bool khr) const {
4757 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004758 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004759 if (offset & 3) {
4760 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004761 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004762 }
4763
4764 if (countBufferOffset & 3) {
4765 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004766 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004767 countBufferOffset);
4768 }
4769 return skip;
4770}
4771
4772bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4773 VkDeviceSize offset, VkBuffer countBuffer,
4774 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4775 uint32_t stride) const {
4776 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4777}
4778
4779bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4780 VkDeviceSize offset, VkBuffer countBuffer,
4781 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4782 uint32_t stride) const {
4783 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4784}
4785
4786bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4787 VkDeviceSize countBufferOffset, bool khr) const {
4788 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004789 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004790 if (offset & 3) {
4791 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004792 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004793 }
4794
4795 if (countBufferOffset & 3) {
4796 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004797 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004798 countBufferOffset);
4799 }
4800 return skip;
4801}
4802
4803bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4804 VkDeviceSize offset, VkBuffer countBuffer,
4805 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4806 uint32_t stride) const {
4807 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4808}
4809
4810bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4811 VkDeviceSize offset, VkBuffer countBuffer,
4812 VkDeviceSize countBufferOffset,
4813 uint32_t maxDrawCount, uint32_t stride) const {
4814 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4815}
4816
Tony-LunarG4490de42021-06-21 15:49:19 -06004817bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4818 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4819 uint32_t firstInstance, uint32_t stride) const {
4820 bool skip = false;
4821 if (stride & 3) {
4822 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4823 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4824 }
4825 if (drawCount && nullptr == pVertexInfo) {
4826 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4827 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4828 "one or more valid instances of VkMultiDrawInfoEXT structures");
4829 }
4830 return skip;
4831}
4832
4833bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4834 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4835 uint32_t instanceCount, uint32_t firstInstance,
4836 uint32_t stride, const int32_t *pVertexOffset) const {
4837 bool skip = false;
4838 if (stride & 3) {
4839 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4840 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4841 }
4842 if (drawCount && nullptr == pIndexInfo) {
4843 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4844 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4845 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4846 }
4847 return skip;
4848}
4849
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004850bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4851 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004852 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004853 bool skip = false;
4854 for (uint32_t rect = 0; rect < rectCount; rect++) {
4855 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004856 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004857 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004858 }
sfricke-samsung10867682020-04-25 02:20:39 -07004859 if (pRects[rect].rect.extent.width == 0) {
4860 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004861 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004862 }
4863 if (pRects[rect].rect.extent.height == 0) {
4864 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004865 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004866 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004867 }
4868 return skip;
4869}
4870
Andrew Fobel3abeb992020-01-20 16:33:22 -05004871bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4872 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4873 VkImageFormatProperties2 *pImageFormatProperties,
4874 const char *apiName) const {
4875 bool skip = false;
4876
4877 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004878 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004879 if (image_stencil_struct != nullptr) {
4880 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4881 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4882 // No flags other than the legal attachment bits may be set
4883 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4884 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004885 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4886 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4887 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4888 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4889 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004890 }
4891 }
4892 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004893 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4894 if (image_drm_format) {
4895 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4896 skip |= LogError(
4897 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4898 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4899 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4900 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4901 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004902 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4903 skip |= LogError(
4904 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4905 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4906 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4907 apiName, image_drm_format->queueFamilyIndexCount);
4908 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004909 } else {
4910 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4911 skip |= LogError(
4912 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4913 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4914 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4915 apiName);
4916 }
4917 }
4918 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4919 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4920 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4921 if (!format_list || format_list->viewFormatCount == 0) {
4922 skip |= LogError(
4923 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4924 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4925 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4926 apiName);
4927 }
4928 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004929 }
4930
4931 return skip;
4932}
4933
4934bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4935 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4936 VkImageFormatProperties2 *pImageFormatProperties) const {
4937 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4938 "vkGetPhysicalDeviceImageFormatProperties2");
4939}
4940
4941bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4942 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4943 VkImageFormatProperties2 *pImageFormatProperties) const {
4944 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4945 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4946}
4947
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004948bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4949 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4950 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4951 bool skip = false;
4952
4953 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4954 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4955 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4956 }
4957
4958 return skip;
4959}
4960
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004961bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4962 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4963 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4964 bool skip = false;
4965
4966 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4967 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4968 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4969 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4970 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4971 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4972 }
4973
ziga-lunarg42f884b2021-08-25 16:13:20 +02004974 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004975}
4976
sfricke-samsung3999ef62020-02-09 17:05:59 -08004977bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4978 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4979 bool skip = false;
4980
4981 if (pRegions != nullptr) {
4982 for (uint32_t i = 0; i < regionCount; i++) {
4983 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004984 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004985 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004986 }
4987 }
4988 }
4989 return skip;
4990}
4991
Jeff Leger178b1e52020-10-05 12:22:23 -04004992bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4993 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4994 bool skip = false;
4995
4996 if (pCopyBufferInfo->pRegions != nullptr) {
4997 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4998 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004999 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005000 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04005001 }
5002 }
5003 }
5004 return skip;
5005}
5006
Tony-LunarGef035472021-11-02 10:23:33 -06005007bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
5008 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
5009 bool skip = false;
5010
5011 if (pCopyBufferInfo->pRegions != nullptr) {
5012 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5013 if (pCopyBufferInfo->pRegions[i].size == 0) {
5014 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
5015 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
5016 }
5017 }
5018 }
5019 return skip;
5020}
5021
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005022bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005023 VkDeviceSize dstOffset, VkDeviceSize dataSize,
5024 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005025 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005026
5027 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005028 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5029 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5030 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005031 }
5032
5033 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005034 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5035 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5036 "), must be greater than zero and less than or equal to 65536.",
5037 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005038 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005039 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5040 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5041 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005042 }
5043 return skip;
5044}
5045
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005046bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005047 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005048 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005049
5050 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005051 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5052 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5053 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005054 }
5055
5056 if (size != VK_WHOLE_SIZE) {
5057 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005058 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005059 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5060 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005061 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005062 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5063 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005064 }
5065 }
5066 return skip;
5067}
5068
sfricke-samsunga1d00272021-03-10 21:37:41 -08005069bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005070 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005071
5072 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005073 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5074 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5075 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5076 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005077 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005078 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5079 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5080 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005081 }
5082
5083 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5084 // queueFamilyIndexCount uint32_t values
5085 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005086 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005087 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005088 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005089 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5090 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005091 }
5092 }
5093
Dave Houlton413a6782018-05-22 13:01:54 -06005094 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005095 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005096
sfricke-samsunga1d00272021-03-10 21:37:41 -08005097 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5098 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5099 if (format_list_info) {
5100 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5101 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5102 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5103 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005104 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5105 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005106 func_name, viewFormatCount);
5107 }
5108
5109 // Using the first format, compare the rest of the formats against it that they are compatible
5110 for (uint32_t i = 1; i < viewFormatCount; i++) {
5111 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5112 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5113 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5114 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005115 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5116 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005117 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5118 string_VkFormat(format_list_info->pViewFormats[i]));
5119 }
5120 }
5121 }
5122
5123 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5124 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5125 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5126 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5127 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5128 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5129 func_name);
5130 } else {
5131 if (format_list_info == nullptr) {
5132 skip |= LogError(
5133 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5134 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5135 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5136 func_name);
5137 } else if (format_list_info->viewFormatCount == 0) {
5138 skip |= LogError(
5139 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5140 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5141 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5142 func_name);
5143 } else {
5144 bool found_base_format = false;
5145 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5146 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5147 found_base_format = true;
5148 break;
5149 }
5150 }
5151 if (!found_base_format) {
5152 skip |=
5153 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5154 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5155 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5156 "pCreateInfo->imageFormat.",
5157 func_name);
5158 }
5159 }
5160 }
5161 }
5162 }
5163 return skip;
5164}
5165
5166bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5167 const VkAllocationCallbacks *pAllocator,
5168 VkSwapchainKHR *pSwapchain) const {
5169 bool skip = false;
5170 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5171 return skip;
5172}
5173
5174bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5175 const VkSwapchainCreateInfoKHR *pCreateInfos,
5176 const VkAllocationCallbacks *pAllocator,
5177 VkSwapchainKHR *pSwapchains) const {
5178 bool skip = false;
5179 if (pCreateInfos) {
5180 for (uint32_t i = 0; i < swapchainCount; i++) {
5181 std::stringstream func_name;
5182 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5183 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5184 }
5185 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005186 return skip;
5187}
5188
Jeff Bolz5c801d12019-10-09 10:38:45 -05005189bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005190 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005191
5192 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005193 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005194 if (present_regions) {
5195 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005196 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005197 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5198 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005199 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005200 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5201 "extension swapchainCount is %i. These values must be equal.",
5202 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005203 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005204 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005205 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5206 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005207 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5208 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5209 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005210 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005211 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005212 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005213 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005214 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005215 }
5216 }
5217
5218 return skip;
5219}
5220
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005221bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5222 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5223 const VkAllocationCallbacks *pAllocator,
5224 VkDisplayModeKHR *pMode) const {
5225 bool skip = false;
5226
5227 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5228 if (display_mode_parameters.visibleRegion.width == 0) {
5229 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5230 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5231 }
5232 if (display_mode_parameters.visibleRegion.height == 0) {
5233 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5234 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5235 }
5236 if (display_mode_parameters.refreshRate == 0) {
5237 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5238 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5239 }
5240
5241 return skip;
5242}
5243
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005244#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005245bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5246 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5247 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005248 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005249 bool skip = false;
5250
5251 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005252 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5253 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005254 }
5255
5256 return skip;
5257}
5258#endif // VK_USE_PLATFORM_WIN32_KHR
5259
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005260static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5261 bool partial_overlap = false;
5262
5263 static const std::vector<VkDescriptorType> all_descriptor_types = {
5264 VK_DESCRIPTOR_TYPE_SAMPLER,
5265 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5266 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5267 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5268 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5269 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5270 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5271 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5272 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5273 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5274 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5275 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5276 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5277 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5278 };
5279
5280 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5281 if (mutable_descriptor_type) {
5282 std::vector<VkDescriptorType> first_types, second_types;
5283 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5284 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5285 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5286 }
5287 } else {
5288 first_types = all_descriptor_types;
5289 }
5290 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5291 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5292 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5293 }
5294 } else {
5295 second_types = all_descriptor_types;
5296 }
5297
5298 bool complete_overlap = first_types.size() == second_types.size();
5299 bool disjoint = true;
5300 for (const auto first_type : first_types) {
5301 bool found = false;
5302 for (const auto second_type : second_types) {
5303 if (first_type == second_type) {
5304 found = true;
5305 break;
5306 }
5307 }
5308 if (found) {
5309 disjoint = false;
5310 } else {
5311 complete_overlap = false;
5312 }
5313 if (!disjoint && !complete_overlap) {
5314 partial_overlap = true;
5315 break;
5316 }
5317 }
5318 }
5319
5320 return partial_overlap;
5321}
5322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005323bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005324 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005325 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005326 bool skip = false;
5327
5328 if (pCreateInfo) {
5329 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005330 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5331 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005332 }
5333
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005334 const auto *mutable_descriptor_type_features =
5335 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5336 bool mutable_descriptor_type_enabled =
5337 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5338
Petr Krausc8655be2017-09-27 18:56:51 +02005339 if (pCreateInfo->pPoolSizes) {
5340 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5341 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005342 skip |= LogError(
5343 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005344 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005345 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005346 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5347 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005348 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5349 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5350 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5351 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5352 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005353 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005354 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5355 skip |=
5356 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5357 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5358 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5359 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5360 i);
5361 }
5362 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5363 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5364 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5365 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5366 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5367 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5368 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5369 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5370 " and have sets which partially overlap.",
5371 i, j);
5372 }
5373 }
5374 }
5375 }
Petr Krausc8655be2017-09-27 18:56:51 +02005376 }
5377 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005378
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005379 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5380 skip |=
5381 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5382 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5383 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5384 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005385 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5386 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5387 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5388 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5389 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5390 }
Petr Krausc8655be2017-09-27 18:56:51 +02005391 }
5392
5393 return skip;
5394}
5395
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005396bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005397 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005398 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005399
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005400 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005401 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005402 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5403 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5404 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005405 }
5406
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005407 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005408 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005409 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5410 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5411 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005412 }
5413
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005414 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005415 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005416 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5417 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5418 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005419 }
5420
5421 return skip;
5422}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005423
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005424bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005425 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005426 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005427
5428 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005429 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5430 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005431 }
5432 return skip;
5433}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005434
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005435bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5436 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005437 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005438 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005439
5440 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005441 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005442 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005443 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5444 "vkCmdDispatch(): baseGroupX (%" PRIu32
5445 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5446 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005447 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005448 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5449 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5450 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5451 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005452 }
5453
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005454 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005455 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005456 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5457 "vkCmdDispatch(): baseGroupY (%" PRIu32
5458 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5459 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005460 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005461 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5462 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5463 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5464 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005465 }
5466
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005467 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005468 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005469 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5470 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5471 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5472 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005473 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005474 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5475 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5476 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5477 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005478 }
5479
5480 return skip;
5481}
5482
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005483bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5484 VkPipelineBindPoint pipelineBindPoint,
5485 VkPipelineLayout layout, uint32_t set,
5486 uint32_t descriptorWriteCount,
5487 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005488 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005489}
5490
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005491bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5492 uint32_t firstExclusiveScissor,
5493 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005494 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005495 bool skip = false;
5496
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005497 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005498 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005499 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005500 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5501 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5502 ") is not 0.",
5503 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005504 }
5505 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005506 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005507 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5508 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5509 ") is not 1.",
5510 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005511 }
5512 } else { // multiViewport enabled
5513 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005514 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005515 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5516 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5517 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5518 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005519 }
5520 }
5521
Jeff Bolz3e71f782018-08-29 23:15:45 -05005522 if (pExclusiveScissors) {
5523 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5524 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5525
5526 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005527 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5528 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5529 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005530 }
5531
5532 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005533 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5534 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5535 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005536 }
5537
5538 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5539 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005540 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5541 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5542 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5543 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005544 }
5545
5546 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5547 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005548 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5549 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5550 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5551 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005552 }
5553 }
5554 }
5555
5556 return skip;
5557}
5558
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005559bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5560 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005561 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005562 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005563 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5564 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5565 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5566 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5567 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5568 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005569 }
5570
5571 return skip;
5572}
5573
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005574bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5575 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005576 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005577 bool skip = false;
5578
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005579 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005580 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005581 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005582 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5583 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5584 ") is not 0.",
5585 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005586 }
5587 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005588 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005589 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5590 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5591 ") is not 1.",
5592 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005593 }
5594 }
5595
Jeff Bolz9af91c52018-09-01 21:53:57 -05005596 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005597 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005598 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5599 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5600 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5601 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005602 }
5603
5604 return skip;
5605}
5606
Jeff Bolz5c801d12019-10-09 10:38:45 -05005607bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5608 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5609 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005610 bool skip = false;
5611
Dave Houlton142c4cb2018-10-17 15:04:41 -06005612 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005613 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5614 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5615 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005616 }
5617
5618 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005619 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005620 }
5621
5622 return skip;
5623}
5624
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005625bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005626 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005627 bool skip = false;
5628
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005629 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005630 skip |= LogError(
5631 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005632 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5633 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005634 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005635 }
5636
5637 return skip;
5638}
5639
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005640bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5641 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005642 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005643 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005644 static const int condition_multiples = 0b0011;
5645 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005646 skip |= LogError(
5647 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005648 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005649 }
Lockee1c22882019-06-10 16:02:54 -06005650 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005651 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5652 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5653 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5654 stride);
Lockee1c22882019-06-10 16:02:54 -06005655 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005656 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005657 skip |= LogError(
5658 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005659 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5660 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005661 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005662 if (drawCount > device_limits.maxDrawIndirectCount) {
5663 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005664 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5665 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005666 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005667 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005668 return skip;
5669}
5670
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005671bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5672 VkDeviceSize offset, VkBuffer countBuffer,
5673 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005674 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005675 bool skip = false;
5676
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005677 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005678 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5679 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5680 "), is not a multiple of 4.",
5681 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005682 }
5683
5684 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005685 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5686 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5687 "), is not a multiple of 4.",
5688 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005689 }
5690
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005691 return skip;
5692}
5693
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005694bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005695 const VkAllocationCallbacks *pAllocator,
5696 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005697 bool skip = false;
5698
5699 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5700 if (pCreateInfo != nullptr) {
5701 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5702 // VkQueryPipelineStatisticFlagBits values
5703 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5704 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005705 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5706 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5707 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5708 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005709 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005710 if (pCreateInfo->queryCount == 0) {
5711 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5712 "vkCreateQueryPool(): queryCount must be greater than zero.");
5713 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005714 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005715 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005716}
5717
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005718bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5719 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005720 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005721 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5722 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005723}
5724
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005725void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005726 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5727 VkResult result) {
5728 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005729 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005730}
5731
Mike Schuchardt2df08912020-12-15 16:28:09 -08005732void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005733 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5734 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005735 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005736 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005737 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005738}
5739
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005740void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5741 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005742 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005743 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005744 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005745}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005746
Tony-LunarG3c287f62020-12-17 12:39:49 -07005747void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005748 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005749 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005750 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005751 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005752 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005753 }
5754 }
5755}
5756
5757void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005758 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005759 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005760 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5761 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5762 }
5763}
5764
5765void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005766 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005767 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005768 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5769 if (item->second == commandPool) {
5770 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005771 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005772 ++item;
5773 }
5774 }
5775}
5776
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005777bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005778 const VkAllocationCallbacks *pAllocator,
5779 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005780 bool skip = false;
5781
5782 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005783 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005784 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005785 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5786 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005787 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005788
5789 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005790 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005791 if (flags_info) {
5792 flags = flags_info->flags;
5793 }
5794
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005795 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005796 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005797 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005798 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5799 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005800 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005801 }
5802
5803#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005804 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005805#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005806 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5807 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005808#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005809 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005810#endif
5811
5812 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005813 skip |= LogError(
5814 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005815 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5816 }
5817 if (
5818#ifdef VK_USE_PLATFORM_WIN32_KHR
5819 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5820#endif
5821 (import_memory_fd && import_memory_fd->handleType) ||
5822#ifdef VK_USE_PLATFORM_ANDROID_KHR
5823 (import_memory_ahb && import_memory_ahb->buffer) ||
5824#endif
5825 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005826 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5827 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005828 }
5829 }
5830
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005831 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5832 if (export_memory) {
5833 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5834 if (export_memory_nv) {
5835 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5836 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5837 "VkExportMemoryAllocateInfoNV");
5838 }
5839#ifdef VK_USE_PLATFORM_WIN32_KHR
5840 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5841 if (export_memory_win32_nv) {
5842 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5843 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5844 "VkExportMemoryWin32HandleInfoNV");
5845 }
5846#endif
5847 }
5848
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005849 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005850 VkBool32 capture_replay = false;
5851 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005852 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005853 if (vulkan_12_features) {
5854 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5855 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5856 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005857 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005858 if (bda_features) {
5859 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5860 buffer_device_address = bda_features->bufferDeviceAddress;
5861 }
5862 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005863 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005864 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005865 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005866 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005867 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005868 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005869 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005870 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005871 }
5872 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005873 }
5874 return skip;
5875}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005876
Jason Macnak192fa0e2019-07-26 15:07:16 -07005877bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005878 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005879 bool skip = false;
5880
5881 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5882 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5883 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005884 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005885 } else {
5886 uint32_t vertex_component_size = 0;
5887 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5888 vertex_component_size = 4;
5889 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5890 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5891 vertex_component_size = 2;
5892 }
5893 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005894 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005895 }
5896 }
5897
5898 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5899 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005900 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005901 } else {
5902 uint32_t index_element_size = 0;
5903 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5904 index_element_size = 4;
5905 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5906 index_element_size = 2;
5907 }
5908 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005909 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005910 }
5911 }
5912 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5913 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005914 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005915 }
5916 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005917 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005918 }
5919 }
5920
5921 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005922 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005923 }
5924
5925 return skip;
5926}
5927
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005928bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5929 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005930 bool skip = false;
5931
5932 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005933 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005934 }
5935 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005936 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005937 }
5938
5939 return skip;
5940}
5941
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005942bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5943 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005944 bool skip = false;
5945 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005946 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005947 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005948 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005949 }
5950 return skip;
5951}
5952
5953bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005954 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005955 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005956 bool skip = false;
5957 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005958 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5959 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5960 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005961 }
5962 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005963 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5964 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5965 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005966 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005967 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5968 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5969 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5970 }
Jason Macnak5c954952019-07-09 15:46:12 -07005971 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5972 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005973 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5974 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5975 "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 -07005976 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005977 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005978 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005979 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5980 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005981 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5982 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005983 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005984 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005985 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5986 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5987 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005988 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005989 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005990 uint64_t total_triangle_count = 0;
5991 for (uint32_t i = 0; i < info.geometryCount; i++) {
5992 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005993
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005994 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005995
Jason Macnak5c954952019-07-09 15:46:12 -07005996 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5997 continue;
5998 }
5999 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
6000 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006001 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006002 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
6003 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
6004 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006005 }
6006 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006007 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
6008 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
6009 for (uint32_t i = 1; i < info.geometryCount; i++) {
6010 const VkGeometryNV &geometry = info.pGeometries[i];
6011 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006012 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006013 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
6014 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006015 "info.pGeometries[0].geometryType.",
6016 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07006017 }
6018 }
6019 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006020 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
6021 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
6022 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
6023 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
6024 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
6025 "or VK_GEOMETRY_TYPE_AABBS_NV.");
6026 }
6027 }
6028 skip |=
6029 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006030 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006031 return skip;
6032}
6033
Ricardo Garciaa4935972019-02-21 17:43:18 +01006034bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6035 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006036 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006037 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006038 if (pCreateInfo) {
6039 if ((pCreateInfo->compactedSize != 0) &&
6040 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006041 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6042 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6043 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6044 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006045 }
Jason Macnak5c954952019-07-09 15:46:12 -07006046
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006047 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006048 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006049 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006050 return skip;
6051}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006052
Jeff Bolz5c801d12019-10-09 10:38:45 -05006053bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6054 const VkAccelerationStructureInfoNV *pInfo,
6055 VkBuffer instanceData, VkDeviceSize instanceOffset,
6056 VkBool32 update, VkAccelerationStructureNV dst,
6057 VkAccelerationStructureNV src, VkBuffer scratch,
6058 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006059 bool skip = false;
6060
6061 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006062 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006063 }
6064
6065 return skip;
6066}
6067
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006068bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6069 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6070 VkAccelerationStructureKHR *pAccelerationStructure) const {
6071 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006072 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006073 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006074 if (!acceleration_structure_features ||
6075 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6076 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6077 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6078 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006079 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006080 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6081 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006082 (acceleration_structure_features &&
6083 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006084 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006085 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6086 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6087 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6088 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006089 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006090 if (pCreateInfo->deviceAddress &&
6091 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6092 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6093 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6094 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6095 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006096 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6097 (acceleration_structure_features &&
6098 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6099 skip |= LogError(
6100 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6101 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6102 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6103 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006104 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6105 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006106 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6107 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006108 }
sourav parmar83c31b12020-05-06 12:30:54 -07006109 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006110 return skip;
6111}
6112
Jason Macnak5c954952019-07-09 15:46:12 -07006113bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6114 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006115 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006116 bool skip = false;
6117 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006118 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6119 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006120 }
6121 return skip;
6122}
6123
sourav parmarcd5fb182020-07-17 12:58:44 -07006124bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6125 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6126 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6127 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006128 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006129 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006130 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006131 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006132 }
6133 return skip;
6134}
6135
Peter Chen85366392019-05-14 15:20:11 -04006136bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6137 uint32_t createInfoCount,
6138 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6139 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006140 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006141 bool skip = false;
6142
6143 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006144 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6145 std::stringstream msg;
6146 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6147 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6148 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006149 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006150 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006151 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006152 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6153 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6154 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6155 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006156 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006157
6158 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006159 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006160 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6161 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6162 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6163 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6164 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6165 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6166 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6167 }
6168 }
6169
sourav parmarf4a78252020-04-10 13:04:21 -07006170 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6171 skip |=
6172 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6173 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6174 }
6175 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6176 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6177 skip |=
6178 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6179 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6180 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6181 }
6182 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6183 if (pCreateInfos[i].basePipelineIndex != -1) {
6184 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6185 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6186 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6187 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6188 "and pCreateInfos->basePipelineIndex is not -1.");
6189 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006190 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006191 skip |=
6192 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6193 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6194 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6195 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6196 "that element.");
6197 }
sourav parmarf4a78252020-04-10 13:04:21 -07006198 }
6199 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006200 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006201 skip |=
6202 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6203 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6204 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6205 "commands pCreateInfos parameter.");
6206 }
6207 } else {
6208 if (pCreateInfos[i].basePipelineIndex != -1) {
6209 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6210 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6211 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6212 }
6213 }
6214 }
6215 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6216 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6217 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6218 }
6219 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6220 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6221 "vkCreateRayTracingPipelinesNV: flags must not include "
6222 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6223 }
6224 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6225 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6226 "vkCreateRayTracingPipelinesNV: flags must not include "
6227 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6228 }
6229 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6230 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6231 "vkCreateRayTracingPipelinesNV: flags must not include "
6232 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6233 }
6234 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6235 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6236 "vkCreateRayTracingPipelinesNV: flags must not include "
6237 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6238 }
6239 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6240 skip |= LogError(
6241 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6242 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6243 }
6244 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6245 skip |= LogError(
6246 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6247 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6248 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006249 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6250 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6251 "vkCreateRayTracingPipelinesNV: flags must not include "
6252 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6253 }
6254 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6255 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6256 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6257 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006258 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6259 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6260 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6261 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6262 }
Peter Chen85366392019-05-14 15:20:11 -04006263 }
6264
6265 return skip;
6266}
6267
sourav parmarcd5fb182020-07-17 12:58:44 -07006268bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6269 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6270 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006271 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006272 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006273 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6274 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6275 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006276 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006277 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006278 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6279 std::stringstream msg;
6280 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6281 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006282 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006283 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006284 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6285 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6286 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6287 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6288 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6289 }
6290 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6291 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6292 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6293 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6294 }
6295 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006296 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006297 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006298 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006299 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6300 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6301 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006302 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6303 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6304 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006305 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006306 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006307 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6308 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6309 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6310 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006311 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006312 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6313 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6314 }
6315 }
sourav parmarf4a78252020-04-10 13:04:21 -07006316 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006317 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6318 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006319 }
6320 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006321 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006322 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006323 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6324 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006325 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006326 }
6327 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6328 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6329 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006330 }
6331 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6332 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6333 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6334 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6335 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6336 skip |= LogError(
6337 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006338 "vkCreateRayTracingPipelinesKHR: If flags includes "
6339 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006340 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6341 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6342 "must not be VK_SHADER_UNUSED_KHR");
6343 }
6344 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6345 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6346 skip |= LogError(
6347 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006348 "vkCreateRayTracingPipelinesKHR: If flags includes "
6349 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006350 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6351 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6352 "element must not be VK_SHADER_UNUSED_KHR");
6353 }
6354 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006355 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6356 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6357 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6358 skip |= LogError(
6359 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6360 "vkCreateRayTracingPipelinesKHR: If "
6361 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6362 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6363 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6364 }
6365 }
sourav parmarf4a78252020-04-10 13:04:21 -07006366 }
6367 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6368 if (pCreateInfos[i].basePipelineIndex != -1) {
6369 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6370 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006371 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006372 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6373 "and pCreateInfos->basePipelineIndex is not -1.");
6374 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006375 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006376 skip |=
6377 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6378 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6379 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6380 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6381 "element.");
6382 }
sourav parmarf4a78252020-04-10 13:04:21 -07006383 }
6384 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006385 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006386 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006387 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006388 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6389 ") must be a valid into the calling"
6390 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006391 pCreateInfos[i].basePipelineIndex, createInfoCount);
6392 }
6393 } else {
6394 if (pCreateInfos[i].basePipelineIndex != -1) {
6395 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006396 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006397 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6398 }
6399 }
6400 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006401 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6402 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6403 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6404 "vkCreateRayTracingPipelinesKHR: If flags includes "
6405 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6406 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006407 }
6408 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6409 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6410 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6411 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6412 "pLibraryInfo and pLibraryInterface must be NULL.");
6413 }
6414 if (pCreateInfos[i].pLibraryInfo) {
6415 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6416 if (pCreateInfos[i].stageCount == 0) {
6417 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6418 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6419 "stageCount must not be 0.");
6420 }
6421 if (pCreateInfos[i].groupCount == 0) {
6422 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6423 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6424 "groupCount must not be 0.");
6425 }
6426 } else {
6427 if (pCreateInfos[i].pLibraryInterface == NULL) {
6428 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6429 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6430 "is greater than 0, its "
6431 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006432 }
6433 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006434 }
6435 if (pCreateInfos[i].pLibraryInterface) {
6436 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6437 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6438 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6439 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6440 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6441 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006442 }
6443 if (deferredOperation != VK_NULL_HANDLE) {
6444 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6445 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6446 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6447 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006448 }
6449 }
ziga-lunargdea76582021-09-17 14:38:08 +02006450 if (pCreateInfos[i].pDynamicState) {
6451 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6452 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6453 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6454 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6455 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6456 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6457 }
6458 }
6459 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006460 }
6461
6462 return skip;
6463}
6464
Mike Schuchardt21638df2019-03-16 10:52:02 -07006465#ifdef VK_USE_PLATFORM_WIN32_KHR
6466bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6467 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006468 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006469 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006470 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006471 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006472 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006473 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006474 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006475 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006476 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006477 skip |=
6478 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006479 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006480 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6481 skip |= validate_struct_type(
6482 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6483 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6484 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6485 if (pSurfaceInfo != NULL) {
6486 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6487 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6488 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6489
6490 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6491 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6492 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6493 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006494 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6495 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006496
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006497 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6498 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6499 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6500 "VK_GOOGLE_surfaceless_query is not enabled.");
6501 }
6502
Mike Schuchardt21638df2019-03-16 10:52:02 -07006503 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6504 }
6505 return skip;
6506}
6507#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006508
6509bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6510 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006511 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006512 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6513 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006514 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006515 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6516 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6517 }
6518 return skip;
6519}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006520
6521bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006522 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006523 bool skip = false;
6524
6525 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006526 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006527 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006528 }
6529
6530 return skip;
6531}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006532
6533bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006534 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006535 bool skip = false;
6536
6537 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006538 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6539 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006540 }
6541
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006542 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006543 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006544 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6545 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006546 }
6547
6548 return skip;
6549}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006550
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006551bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6552 uint32_t bindingCount, const VkBuffer *pBuffers,
6553 const VkDeviceSize *pOffsets) const {
6554 bool skip = false;
6555 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006556 skip |=
6557 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6558 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6559 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006560 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6561 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006562 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6563 ") must be less than "
6564 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006565 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6566 }
6567
Jeff Bolz165818a2020-05-08 11:19:03 -05006568 for (uint32_t i = 0; i < bindingCount; ++i) {
6569 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006570 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006571 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006572 skip |=
6573 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6574 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006575 } else {
6576 if (pOffsets[i] != 0) {
6577 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006578 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6579 "] is not 0",
6580 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006581 }
6582 }
6583 }
6584 }
6585
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006586 return skip;
6587}
6588
Mark Lobodzinski84988402019-09-11 15:27:30 -06006589bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006590 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006591 bool skip = false;
6592 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006593 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6594 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006595 }
6596 return skip;
6597}
6598
6599bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006600 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006601 bool skip = false;
6602 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006603 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6604 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006605 }
6606 return skip;
6607}
Petr Kraus3d720392019-11-13 02:52:39 +01006608
6609bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6610 VkSemaphore semaphore, VkFence fence,
6611 uint32_t *pImageIndex) const {
6612 bool skip = false;
6613
6614 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006615 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6616 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006617 }
6618
6619 return skip;
6620}
6621
6622bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6623 uint32_t *pImageIndex) const {
6624 bool skip = false;
6625
6626 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006627 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6628 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006629 }
6630
6631 return skip;
6632}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006633
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006634bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6635 uint32_t firstBinding, uint32_t bindingCount,
6636 const VkBuffer *pBuffers,
6637 const VkDeviceSize *pOffsets,
6638 const VkDeviceSize *pSizes) const {
6639 bool skip = false;
6640
6641 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6642 for (uint32_t i = 0; i < bindingCount; ++i) {
6643 if (pOffsets[i] & 3) {
6644 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6645 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6646 }
6647 }
6648
6649 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6650 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6651 "%s: The firstBinding(%" PRIu32
6652 ") index is greater than or equal to "
6653 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6654 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6655 }
6656
6657 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6658 skip |=
6659 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6660 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6661 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6662 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6663 }
6664
6665 for (uint32_t i = 0; i < bindingCount; ++i) {
6666 // pSizes is optional and may be nullptr.
6667 if (pSizes != nullptr) {
6668 if (pSizes[i] != VK_WHOLE_SIZE &&
6669 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6670 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6671 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6672 ") is not VK_WHOLE_SIZE and is greater than "
6673 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6674 cmd_name, i, pSizes[i]);
6675 }
6676 }
6677 }
6678
6679 return skip;
6680}
6681
6682bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6683 uint32_t firstCounterBuffer,
6684 uint32_t counterBufferCount,
6685 const VkBuffer *pCounterBuffers,
6686 const VkDeviceSize *pCounterBufferOffsets) const {
6687 bool skip = false;
6688
6689 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6690 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6691 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6692 "%s: The firstCounterBuffer(%" PRIu32
6693 ") index is greater than or equal to "
6694 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6695 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6696 }
6697
6698 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6699 skip |=
6700 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6701 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6702 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6703 cmd_name, firstCounterBuffer, counterBufferCount,
6704 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6705 }
6706
6707 return skip;
6708}
6709
6710bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6711 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6712 const VkBuffer *pCounterBuffers,
6713 const VkDeviceSize *pCounterBufferOffsets) const {
6714 bool skip = false;
6715
6716 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6717 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6718 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6719 "%s: The firstCounterBuffer(%" PRIu32
6720 ") index is greater than or equal to "
6721 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6722 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6723 }
6724
6725 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6726 skip |=
6727 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6728 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6729 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6730 cmd_name, firstCounterBuffer, counterBufferCount,
6731 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6732 }
6733
6734 return skip;
6735}
6736
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006737bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6738 uint32_t firstInstance, VkBuffer counterBuffer,
6739 VkDeviceSize counterBufferOffset,
6740 uint32_t counterOffset, uint32_t vertexStride) const {
6741 bool skip = false;
6742
6743 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006744 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6745 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6746 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6747 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006748 }
6749
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006750 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006751 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006752 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006753 }
6754
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006755 return skip;
6756}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006757
6758bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6759 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6760 const VkAllocationCallbacks *pAllocator,
6761 VkSamplerYcbcrConversion *pYcbcrConversion,
6762 const char *apiName) const {
6763 bool skip = false;
6764
6765 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006766 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006767 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006768 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006769 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6770 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006771 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006772 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006773 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006774
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006775#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006776 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006777 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006778#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006779 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006780#endif
6781
sfricke-samsung1a72f942020-07-25 12:09:18 -07006782 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006783
6784 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006785 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006786 const VkComponentMapping components = pCreateInfo->components;
6787 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6788 if (FormatIsXChromaSubsampled(format) == true) {
6789 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6790 skip |=
6791 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006792 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6793 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006794 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006795 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006796
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006797 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6798 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6799 skip |= LogError(
6800 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6801 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6802 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6803 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6804 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006805
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006806 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6807 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6808 skip |=
6809 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006810 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6811 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006812 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006813 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006814
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006815 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6816 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6817 skip |=
6818 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006819 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6820 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006821 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006822 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006823
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006824 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006825 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6826 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6827 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006828 skip |=
6829 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006830 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6831 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006832 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6833 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006834 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006835 }
6836
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006837 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6838 // Checks same VU multiple ways in order to give a more useful error message
6839 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6840 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6841 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6842 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6843 skip |= LogError(
6844 device, vuid,
6845 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6846 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6847 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6848 string_VkComponentSwizzle(components.b));
6849 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006850
sfricke-samsunged028b02021-09-06 23:14:51 -07006851 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6852 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006853 // 3 = no [a]
6854 // 2 = no [b,a]
6855 // 1 = no [g,b,a]
6856 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006857 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006858
sfricke-samsunged028b02021-09-06 23:14:51 -07006859 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6860 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006861 skip |= LogError(device, vuid,
6862 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6863 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6864 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6865 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006866 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006867 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6868 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6869 skip |= LogError(device, vuid,
6870 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6871 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6872 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6873 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6874 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006875 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006876 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6877 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6878 skip |= LogError(device, vuid,
6879 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6880 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6881 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6882 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6883 string_VkComponentSwizzle(components.b));
6884 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006885 }
6886 }
6887
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006888 return skip;
6889}
6890
6891bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6892 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6893 const VkAllocationCallbacks *pAllocator,
6894 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6895 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6896 "vkCreateSamplerYcbcrConversion");
6897}
6898
6899bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6900 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6901 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6902 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6903 "vkCreateSamplerYcbcrConversionKHR");
6904}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006905
6906bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6907 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6908 bool skip = false;
6909 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6910 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6911
6912 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006913 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6914 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6915 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6916 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6917 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006918 }
6919 return skip;
6920}
sourav parmara96ab1a2020-04-25 16:28:23 -07006921
6922bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006923 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006924 bool skip = false;
6925 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6926 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6927 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6928 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006929 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006930 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6931 skip |= LogError(
6932 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6933 "vkCopyAccelerationStructureToMemoryKHR: The "
6934 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6935 }
6936 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6937 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6938 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6939 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6940 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6941 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006942 return skip;
6943}
6944
6945bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6946 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6947 bool skip = false;
6948 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6949 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6950 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6951 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6952 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006953 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6954 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006955 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006956 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006957 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006958 return skip;
6959}
6960
6961bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6962 const char *api_name) const {
6963 bool skip = false;
6964 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6965 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6966 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6967 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6968 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6969 api_name);
6970 }
6971 return skip;
6972}
6973
6974bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006975 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006976 bool skip = false;
6977 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006978 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006979 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006980 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006981 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6982 "vkCopyAccelerationStructureKHR: The "
6983 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006984 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006985 return skip;
6986}
6987
6988bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6989 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6990 bool skip = false;
6991 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6992 return skip;
6993}
6994
6995bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006996 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006997 bool skip = false;
6998 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006999 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07007000 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
7001 }
7002 return skip;
7003}
7004
7005bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007006 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007007 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007008 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007009 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007010 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7011 skip |= LogError(
7012 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
7013 "vkCopyMemoryToAccelerationStructureKHR: The "
7014 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007015 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007016 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
7017 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07007018 return skip;
7019}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06007020
sourav parmara96ab1a2020-04-25 16:28:23 -07007021bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
7022 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
7023 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007024 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07007025 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
7026 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007027 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007028 pInfo->src.deviceAddress);
7029 }
sourav parmar83c31b12020-05-06 12:30:54 -07007030 return skip;
7031}
7032bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7033 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7034 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7035 bool skip = false;
7036 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7037 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007038 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7039 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7040 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7041 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7042 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7043 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7044 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7045 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7046 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7047 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7048 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7049 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7050 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7051 }
sourav parmar83c31b12020-05-06 12:30:54 -07007052 }
7053 return skip;
7054}
7055bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7056 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7057 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7058 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007059 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007060 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7061 skip |= LogError(
7062 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7063 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7064 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7065 }
sourav parmar83c31b12020-05-06 12:30:54 -07007066 if (dataSize < accelerationStructureCount * stride) {
7067 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7068 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007069 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007070 dataSize, accelerationStructureCount, stride);
7071 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007072
sourav parmar83c31b12020-05-06 12:30:54 -07007073 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7074 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007075 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7076 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7077 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7078 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7079 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7080 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7081 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7082 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7083 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7084 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7085 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7086 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7087 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7088 }
sourav parmar83c31b12020-05-06 12:30:54 -07007089 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007090
7091 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7092 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007093 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7094 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7095 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7096 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7097 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007098 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007099 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7100 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7101 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7102 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7103 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007104 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7105 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7106 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7107 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7108 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7109 stride);
7110 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7111 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7112 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7113 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7114 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7115 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007116 }
7117 }
sourav parmar83c31b12020-05-06 12:30:54 -07007118 return skip;
7119}
7120bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7121 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7122 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007123 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007124 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7125 skip |= LogError(
7126 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7127 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7128 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007129 }
7130 return skip;
7131}
7132
7133bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007134 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7135 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7136 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7137 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007138 uint32_t width, uint32_t height, uint32_t depth) const {
7139 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007140 // RayGen
7141 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7142 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7143 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007144 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007145 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7146 0) {
7147 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7148 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7149 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7150 }
7151 // Callable
7152 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7153 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7154 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7155 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007156 }
7157 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7158 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7159 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007160 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7161 }
7162 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7163 0) {
7164 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7165 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7166 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007167 }
7168 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007169 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7170 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7171 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7172 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007173 }
7174 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7175 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007176 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7177 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007178 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007179 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7180 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7181 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7182 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7183 }
sourav parmar83c31b12020-05-06 12:30:54 -07007184 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007185 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7186 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7187 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7188 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007189 }
7190 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7191 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7192 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007193 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7194 }
7195 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7196 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7197 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7198 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7199 }
7200 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007201 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007202 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7203 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7204 }
7205 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7206 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007207 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007208 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7209 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007210 }
7211
sourav parmarcd5fb182020-07-17 12:58:44 -07007212 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7213 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007214 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007215 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7216 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7217 }
7218
7219 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7220 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007221 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007222 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7223 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007224 }
7225 return skip;
7226}
7227
sourav parmarcd5fb182020-07-17 12:58:44 -07007228bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7229 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7230 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7231 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007232 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007233 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007234 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7235 skip |= LogError(
7236 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7237 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7238 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007239 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007240 // RayGen
7241 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7242 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-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-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7248 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7249 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7250 }
7251 // Callabe
7252 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7253 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7254 "vkCmdTraceRaysIndirectKHR: 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-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007259 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7260 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7261 }
7262 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7263 0) {
7264 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7265 "vkCmdTraceRaysIndirectKHR: 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-vkCmdTraceRaysIndirectKHR-stride-03690",
7271 "vkCmdTraceRaysIndirectKHR: 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-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007276 "vkCmdTraceRaysIndirectKHR: The 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-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7281 "vkCmdTraceRaysIndirectKHR: 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-vkCmdTraceRaysIndirectKHR-stride-03686",
7287 "vkCmdTraceRaysIndirectKHR: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-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007292 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7293 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7294 }
7295 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7296 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7297 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7298 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007299 }
7300
sourav parmarcd5fb182020-07-17 12:58:44 -07007301 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7302 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7303 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007304 }
7305 return skip;
7306}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007307
7308bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7309 VkDeviceAddress indirectDeviceAddress) const {
7310 bool skip = false;
7311 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7312 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7313 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007314 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007315 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7316 "feature must be enabled.");
7317 }
7318
7319 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7320 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7321 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7322 }
7323 return skip;
7324}
7325
sourav parmar83c31b12020-05-06 12:30:54 -07007326bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7327 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7328 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7329 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7330 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7331 uint32_t width, uint32_t height, uint32_t depth) const {
7332 bool skip = false;
7333 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7334 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7335 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7336 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7337 }
7338 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7339 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7340 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7341 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7342 }
7343 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7344 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7345 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7346 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7347 }
7348
7349 // hitShader
7350 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7351 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7352 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7353 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7354 }
7355 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7356 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7357 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7358 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7359 }
7360 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7361 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7362 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7363 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7364 }
7365
7366 // missShader
7367 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7368 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7369 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7370 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7371 }
7372 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7373 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7374 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7375 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7376 }
7377 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7378 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7379 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7380 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7381 }
7382
7383 // raygenShader
7384 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7385 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7386 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007387 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7388 }
7389 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7390 skip |=
7391 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7392 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7393 }
7394 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7395 skip |=
7396 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7397 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7398 }
7399 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7400 skip |=
7401 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7402 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007403 }
7404 return skip;
7405}
7406
sourav parmar83c31b12020-05-06 12:30:54 -07007407bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007408 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7409 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007410 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007411 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7412 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007413 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7414 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007415 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007416 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7417 }
7418 return skip;
7419}
7420
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007421bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7422 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007423 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007424 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007425
7426 if (!physical_device_features.multiViewport) {
7427 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007428 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7429 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007430 viewportCount);
7431 }
7432 } else { // multiViewport enabled
7433 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007434 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7435 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007436 ") must "
7437 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007438 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007439 }
7440 }
7441
7442 if (pViewports) {
7443 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7444 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007445 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007446 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007447 }
7448 }
7449
7450 return skip;
7451}
7452
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007453bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7454 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007455 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007456 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7457 return skip;
7458}
7459
7460bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7461 const VkViewport *pViewports) const {
7462 bool skip = false;
7463 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7464 return skip;
7465}
7466
7467bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7468 const VkRect2D *pScissors, bool is_ext) const {
7469 bool skip = false;
7470 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007471
7472 if (!physical_device_features.multiViewport) {
7473 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007474 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7475 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007476 ") must "
7477 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007478 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007479 }
7480 } else { // multiViewport enabled
7481 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007482 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7483 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007484 ") must "
7485 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007486 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007487 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007488 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7489 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007490 ") must "
7491 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007492 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007493 }
7494 }
7495
7496 if (pScissors) {
7497 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7498 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7499
7500 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007501 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7502 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007503 }
7504
7505 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007506 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7507 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007508 }
7509
7510 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7511 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007512 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7513 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7514 "] will overflow int32_t.",
7515 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007516 }
7517
7518 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7519 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007520 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7521 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7522 "] will overflow int32_t.",
7523 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7524 }
7525 }
7526 }
7527
7528 return skip;
7529}
7530
7531bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7532 const VkRect2D *pScissors) const {
7533 bool skip = false;
7534 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7535 return skip;
7536}
7537
7538bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7539 const VkRect2D *pScissors) const {
7540 bool skip = false;
7541 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7542 return skip;
7543}
7544
7545bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7546 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7547 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7548 bool is_2ext) const {
7549 bool skip = false;
7550 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7551 if (firstBinding >= device_limits.maxVertexInputBindings) {
7552 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7553 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7554 firstBinding, device_limits.maxVertexInputBindings);
7555 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7556 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7557 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7558 ") must be less than "
7559 "maxVertexInputBindings (%" PRIu32 ")",
7560 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7561 }
7562
7563 for (uint32_t i = 0; i < bindingCount; ++i) {
7564 if (pBuffers[i] == VK_NULL_HANDLE) {
7565 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7566 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7567 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7568 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7569 } else {
7570 if (pOffsets[i] != 0) {
7571 skip |=
7572 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7573 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7574 }
7575 }
7576 }
7577 if (pStrides) {
7578 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7579 skip |=
7580 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7581 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7582 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007583 }
7584 }
7585 }
7586
7587 return skip;
7588}
7589
7590bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7591 uint32_t bindingCount, const VkBuffer *pBuffers,
7592 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7593 const VkDeviceSize *pStrides) const {
7594 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007595 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7596 return skip;
7597}
Piers Daniell39842ee2020-07-10 16:42:33 -06007598
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007599bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7600 uint32_t bindingCount, const VkBuffer *pBuffers,
7601 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7602 const VkDeviceSize *pStrides) const {
7603 bool skip = false;
7604 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007605 return skip;
7606}
sourav parmarcd5fb182020-07-17 12:58:44 -07007607
7608bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7609 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7610 bool skip = false;
7611 for (uint32_t i = 0; i < infoCount; ++i) {
7612 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7613 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7614 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7615 }
7616 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7617 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7618 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7619 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7620 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7621 api_name);
7622 }
7623 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7624 skip |=
7625 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7626 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7627 }
7628 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7629 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7630 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7631 }
7632 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7633 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7634 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7635 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7636 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7637 api_name);
7638 }
7639 if (pInfos[i].pGeometries) {
7640 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7641 skip |= validate_ranged_enum(
7642 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7643 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7644 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7645 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007646 skip |= validate_struct_type(
7647 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7648 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7649 &(pInfos[i].pGeometries[j].geometry.triangles),
7650 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7651 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7652 skip |= validate_struct_pnext(
7653 api_name,
7654 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7655 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7656 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7657 skip |=
7658 validate_ranged_enum(api_name,
7659 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7660 ParameterName::IndexVector{i, j}),
7661 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7662 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7663 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7664 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7665 &pInfos[i].pGeometries[j].geometry.triangles,
7666 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7667 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7668 skip |= validate_ranged_enum(
7669 api_name,
7670 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7671 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7672 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7673
7674 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7675 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7676 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7677 }
7678 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7679 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7680 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7681 skip |=
7682 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7683 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7684 api_name);
7685 }
7686 }
7687 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7688 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7689 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7690 &pInfos[i].pGeometries[j].geometry.instances,
7691 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7692 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7693 skip |= validate_struct_type(
7694 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7695 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7696 &(pInfos[i].pGeometries[j].geometry.instances),
7697 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7698 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7699 skip |= validate_struct_pnext(
7700 api_name,
7701 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7702 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7703 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7704
7705 skip |= validate_bool32(api_name,
7706 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7707 ParameterName::IndexVector{i, j}),
7708 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7709 }
7710 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7711 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7712 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7713 &pInfos[i].pGeometries[j].geometry.aabbs,
7714 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7715 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7716 skip |= validate_struct_type(
7717 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7718 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7719 &(pInfos[i].pGeometries[j].geometry.aabbs),
7720 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7721 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7722 skip |= validate_struct_pnext(
7723 api_name,
7724 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7725 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7726 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7727 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7728 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7729 "(%s):stride must be less than or equal to 2^32-1", api_name);
7730 }
7731 }
7732 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7733 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7734 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7735 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7736 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7737 api_name);
7738 }
7739 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7740 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7741 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7742 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7743 "of elements of"
7744 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7745 api_name);
7746 }
7747 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7748 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7749 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7750 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7751 api_name);
7752 }
7753 }
7754 }
7755 }
7756 if (pInfos[i].ppGeometries != NULL) {
7757 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7758 skip |= validate_ranged_enum(
7759 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7760 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7761 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7762 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007763 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].ppGeometries[j]->geometry.triangles,
7766 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7767 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7768 skip |= validate_struct_type(
7769 api_name,
7770 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7771 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7772 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7773 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7774 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7775 skip |= validate_struct_pnext(
7776 api_name,
7777 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7778 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7779 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7780 skip |= validate_ranged_enum(api_name,
7781 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7782 ParameterName::IndexVector{i, j}),
7783 "VkFormat", AllVkFormatEnums,
7784 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7785 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7786 skip |= validate_ranged_enum(api_name,
7787 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7788 ParameterName::IndexVector{i, j}),
7789 "VkIndexType", AllVkIndexTypeEnums,
7790 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7791 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7792 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7793 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7794 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7795 }
7796 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7797 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7798 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7799 skip |=
7800 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7801 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7802 api_name);
7803 }
7804 }
7805 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7806 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7807 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7808 &pInfos[i].ppGeometries[j]->geometry.instances,
7809 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7810 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7811 skip |= validate_struct_type(
7812 api_name,
7813 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7814 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7815 &(pInfos[i].ppGeometries[j]->geometry.instances),
7816 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7817 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7818 skip |= validate_struct_pnext(
7819 api_name,
7820 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7821 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7822 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7823 skip |= validate_bool32(api_name,
7824 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7825 ParameterName::IndexVector{i, j}),
7826 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7827 }
7828 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7829 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7830 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7831 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7832 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7833 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7834 skip |= validate_struct_type(
7835 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7836 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7837 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7838 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7839 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7840 skip |= validate_struct_pnext(
7841 api_name,
7842 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7843 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7844 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7845 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7846 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7847 "(%s):stride must be less than or equal to 2^32-1", api_name);
7848 }
7849 }
7850 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7851 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7852 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7853 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7854 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7855 api_name);
7856 }
7857 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7858 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7859 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7860 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7861 "of elements of"
7862 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7863 api_name);
7864 }
7865 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7866 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7867 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7868 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7869 api_name);
7870 }
7871 }
7872 }
7873 }
7874 }
7875 return skip;
7876}
7877bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7878 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7879 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7880 bool skip = false;
7881 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7882 for (uint32_t i = 0; i < infoCount; ++i) {
7883 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7884 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7885 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7886 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7887 "scratchData.deviceAddress member must be a multiple of "
7888 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7889 }
7890 for (uint32_t k = 0; k < infoCount; ++k) {
7891 if (i == k) continue;
7892 bool found = false;
7893 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007894 skip |=
7895 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7896 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7897 ") of pInfos must "
7898 "not be "
7899 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7900 ") of pInfos.",
7901 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007902 found = true;
7903 }
7904 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007905 skip |=
7906 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7907 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7908 ") of pInfos must "
7909 "not be "
7910 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7911 ") of pInfos.",
7912 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007913 found = true;
7914 }
7915 if (found) break;
7916 }
7917 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7918 if (pInfos[i].pGeometries) {
7919 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7920 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7921 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7922 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7923 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7924 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7925 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7926 }
7927 } else {
7928 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7929 skip |=
7930 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7931 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7932 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7933 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7934 }
7935 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007936 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007937 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7938 skip |= LogError(
7939 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7940 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7941 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7942 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007943 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7944 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007945 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7946 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7947 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7948 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7949 }
7950 }
7951 } else if (pInfos[i].ppGeometries) {
7952 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7953 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7954 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7955 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7956 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7957 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7958 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7959 }
7960 } else {
7961 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7962 skip |=
7963 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7964 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7965 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7966 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7967 }
7968 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007969 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007970 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7971 skip |= LogError(
7972 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7973 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7974 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7975 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007976 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7977 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007978 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7979 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7980 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7981 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7982 }
7983 }
7984 }
7985 }
7986 }
7987 return skip;
7988}
7989
7990bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7991 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7992 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7993 const uint32_t *const *ppMaxPrimitiveCounts) const {
7994 bool skip = false;
7995 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7996 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007997 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007998 if (!ray_tracing_acceleration_structure_features ||
7999 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
8000 skip |= LogError(
8001 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
8002 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
8003 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
8004 }
8005 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008006 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8007 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8008 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
8009 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
8010 "scratchData.deviceAddress member must be a multiple of "
8011 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8012 }
8013 for (uint32_t k = 0; k < infoCount; ++k) {
8014 if (i == k) continue;
8015 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008016 skip |= LogError(
8017 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
8018 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
8019 ") "
8020 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
8021 "any other element [%" PRIu32 ") of pInfos.",
8022 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008023 break;
8024 }
8025 }
8026 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8027 if (pInfos[i].pGeometries) {
8028 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8029 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8030 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8031 skip |= LogError(
8032 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8033 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8034 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8035 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8036 }
8037 } else {
8038 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8039 skip |= LogError(
8040 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8041 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8042 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8043 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8044 }
8045 }
8046 }
8047 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8048 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8049 skip |= LogError(
8050 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8051 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8052 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8053 }
8054 }
8055 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8056 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8057 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8058 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8059 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8060 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8061 }
8062 }
8063 } else if (pInfos[i].ppGeometries) {
8064 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8065 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8066 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8067 skip |= LogError(
8068 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8069 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8070 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8071 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8072 }
8073 } else {
8074 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8075 skip |= LogError(
8076 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8077 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8078 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8079 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8080 }
8081 }
8082 }
8083 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8084 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8085 skip |= LogError(
8086 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8087 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8088 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8089 }
8090 }
8091 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8092 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8093 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8094 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8095 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8096 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8097 }
8098 }
8099 }
8100 }
8101 }
8102 return skip;
8103}
8104
8105bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8106 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8107 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8108 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8109 bool skip = false;
8110 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8111 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008112 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008113 if (!ray_tracing_acceleration_structure_features ||
8114 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8115 skip |=
8116 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8117 "vkBuildAccelerationStructuresKHR: The "
8118 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8119 }
8120 for (uint32_t i = 0; i < infoCount; ++i) {
8121 for (uint32_t j = 0; j < infoCount; ++j) {
8122 if (i == j) continue;
8123 bool found = false;
8124 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008125 skip |=
8126 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8127 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8128 ") of pInfos must "
8129 "not be "
8130 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8131 ") of pInfos.",
8132 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008133 found = true;
8134 }
8135 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008136 skip |=
8137 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8138 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8139 ") of pInfos must "
8140 "not be "
8141 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8142 ") of pInfos.",
8143 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008144 found = true;
8145 }
8146 if (found) break;
8147 }
8148 }
8149 return skip;
8150}
8151
8152bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8153 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8154 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8155 bool skip = false;
8156 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8157 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008158 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8159 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008160 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8161 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008162 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008163 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8164 }
8165 if (pBuildInfo != nullptr) {
8166 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8167 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8168 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8169 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8170 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008171 }
8172 return skip;
8173}
sfricke-samsungecafb192021-01-17 08:21:14 -08008174
Piers Daniellcb6d8032021-04-19 18:51:26 -06008175bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8176 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8177 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8178 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8179 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008180 const auto *vertex_attribute_divisor_features =
8181 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8182
Piers Daniellcb6d8032021-04-19 18:51:26 -06008183 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8184 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8185 skip |=
8186 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8187 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8188 }
8189
8190 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8191 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8192 skip |= LogError(
8193 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8194 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8195 }
8196
8197 // VUID-vkCmdSetVertexInputEXT-binding-04793
8198 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8199 bool binding_found = false;
8200 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8201 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8202 binding_found = true;
8203 break;
8204 }
8205 }
8206 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008207 skip |= LogError(
8208 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8209 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008210 }
8211 }
8212
8213 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8214 if (vertexBindingDescriptionCount > 1) {
8215 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8216 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8217 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8218 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8219 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008220 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8221 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008222 }
8223 }
8224 }
8225 }
8226
8227 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8228 if (vertexAttributeDescriptionCount > 1) {
8229 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8230 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8231 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8232 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8233 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008234 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8235 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008236 }
8237 }
8238 }
8239 }
8240
8241 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8242 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8243 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008244 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8245 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8246 "].binding is greater than maxVertexInputBindings",
8247 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008248 }
8249
8250 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8251 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008252 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8253 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8254 "].stride is greater than maxVertexInputBindingStride",
8255 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008256 }
8257
8258 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8259 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8260 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8261 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008262 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8263 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008264 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8265 binding);
8266 }
8267
8268 if (pVertexBindingDescriptions[binding].divisor > 1) {
8269 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8270 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8271 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008272 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8273 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008274 "vertexAttributeInstanceRateDivisor is not enabled",
8275 binding);
8276 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008277 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008278 if (pVertexBindingDescriptions[binding].divisor >
8279 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008280 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8281 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8282 "].divisor is greater than maxVertexAttribDivisor",
8283 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008284 }
8285
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008286 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008287 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008288 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8289 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8290 "].divisor is greater than 1 but inputRate "
8291 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8292 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008293 }
8294 }
8295 }
8296 }
8297
8298 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008299 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008300 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008301 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8302 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8303 "].location is greater than maxVertexInputAttributes",
8304 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008305 }
8306
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008307 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008308 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008309 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8310 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8311 "].binding is greater than maxVertexInputBindings",
8312 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008313 }
8314
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008315 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008316 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008317 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8318 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8319 "].offset is greater than maxVertexInputAttributeOffset",
8320 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008321 }
8322
8323 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8324 VkFormatProperties properties;
8325 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8326 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8327 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008328 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8329 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008330 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8331 attribute);
8332 }
8333 }
8334
8335 return skip;
8336}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008337
8338bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8339 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8340 const void *pValues) const {
8341 bool skip = false;
8342 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8343 // Check that offset + size don't exceed the max.
8344 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8345 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008346 skip |=
8347 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8348 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8349 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008350 }
8351 if (size > max_push_constants_size - offset) {
8352 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008353 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8354 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008355 offset, size, max_push_constants_size);
8356 }
8357
8358 // size needs to be non-zero and a multiple of 4.
8359 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008360 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8361 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008362 }
8363
8364 // offset needs to be a multiple of 4.
8365 if ((offset & 0x3) != 0) {
8366 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008367 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008368 }
8369 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008370}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008371
8372bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8373 uint32_t srcCacheCount,
8374 const VkPipelineCache *pSrcCaches) const {
8375 bool skip = false;
8376 if (pSrcCaches) {
8377 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8378 if (pSrcCaches[index0] == dstCache) {
8379 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8380 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8381 report_data->FormatHandle(dstCache).c_str());
8382 break;
8383 }
8384 }
8385 }
8386 return skip;
8387}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008388
8389bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8390 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8391 uint32_t rangeCount,
8392 const VkImageSubresourceRange *pRanges) const {
8393 bool skip = false;
8394 if (!pColor) {
8395 skip |=
8396 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8397 }
8398 return skip;
8399}
8400
8401bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8402 const VkRenderPassBeginInfo *const rp_begin) const {
8403 bool skip = false;
8404 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8405 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8406 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008407 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008408 func_name, rp_begin->clearValueCount);
8409 }
8410 return skip;
8411}
8412
8413bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8414 VkSubpassContents) const {
8415 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8416 return skip;
8417}
8418
8419bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8420 const VkRenderPassBeginInfo *pRenderPassBegin,
8421 const VkSubpassBeginInfo *) const {
8422 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8423 return skip;
8424}
8425
8426bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8427 const VkSubpassBeginInfo *) const {
8428 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8429 return skip;
8430}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008431
8432bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8433 uint32_t firstDiscardRectangle,
8434 uint32_t discardRectangleCount,
8435 const VkRect2D *pDiscardRectangles) const {
8436 bool skip = false;
8437
8438 if (pDiscardRectangles) {
8439 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8440 const int64_t x_sum =
8441 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8442 if (x_sum > std::numeric_limits<int32_t>::max()) {
8443 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8444 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8445 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8446 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8447 }
8448
8449 const int64_t y_sum =
8450 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8451 if (y_sum > std::numeric_limits<int32_t>::max()) {
8452 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8453 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8454 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8455 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8456 }
8457 }
8458 }
8459
8460 return skip;
8461}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008462
8463bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8464 uint32_t queryCount, size_t dataSize, void *pData,
8465 VkDeviceSize stride, VkQueryResultFlags flags) const {
8466 bool skip = false;
8467
8468 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8469 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8470 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8471 }
8472
8473 return skip;
8474}
ziga-lunargcf340c42021-08-19 00:13:38 +02008475
8476bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8477 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8478 bool skip = false;
8479
8480 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8481 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8482 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8483 ") is not a multiple of 4.",
8484 pConditionalRenderingBegin->offset);
8485 }
8486
8487 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008488}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008489
8490bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8491 VkSurfaceKHR surface,
8492 uint32_t *pSurfaceFormatCount,
8493 VkSurfaceFormatKHR *pSurfaceFormats) const {
8494 bool skip = false;
8495 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8496 skip |= LogError(
8497 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8498 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8499 }
8500 return skip;
8501}
8502
8503bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8504 VkSurfaceKHR surface,
8505 uint32_t *pPresentModeCount,
8506 VkPresentModeKHR *pPresentModes) const {
8507 bool skip = false;
8508 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8509 skip |= LogError(
8510 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8511 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8512 }
8513 return skip;
8514}
8515
8516bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8517 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8518 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8519 bool skip = false;
8520 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8521 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8522 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8523 "VK_GOOGLE_surfaceless_query is not enabled.");
8524 }
8525 return skip;
8526}
8527
8528bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8529 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8530 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8531 bool skip = false;
8532 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8533 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8534 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8535 "VK_GOOGLE_surfaceless_query is not enabled.");
8536 }
8537 return skip;
8538}
8539
8540#ifdef VK_USE_PLATFORM_WIN32_KHR
8541bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8542 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8543 VkPresentModeKHR *pPresentModes) const {
8544 bool skip = false;
8545 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8546 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8547 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8548 "VK_GOOGLE_surfaceless_query is not enabled.");
8549 }
8550 return skip;
8551}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008552
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008553#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008554
8555bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8556 const char *func_name) const {
8557 bool skip = false;
8558
8559 if (pInfo && pInfo->pCreateInfo) {
8560 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8561 if (image_swapchain_create_info) {
8562 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8563 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8564 }
sjfricke7f73fbd2022-05-27 06:33:36 +09008565 const auto *drm_format_modifier_create_info =
8566 LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pInfo->pCreateInfo);
8567 if (drm_format_modifier_create_info) {
Mike Schuchardt75a4db52022-06-02 14:01:11 -07008568 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirements-pCreateInfo-06776",
sjfricke7f73fbd2022-05-27 06:33:36 +09008569 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageDrmFormatModifierExplicitCreateInfoEXT.",
8570 func_name);
8571 }
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008572 }
8573
8574 return skip;
8575}
8576
8577bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8578 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8579 bool skip = false;
8580
8581 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8582
8583 return skip;
8584}
8585
8586bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8587 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8588 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8589 bool skip = false;
8590
8591 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8592
8593 return skip;
8594}