blob: 38c765a9ef250ab3dce2a38f2945134d1beb5aaf [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) {
587 skip |= LogError(
588 instance, "VUID-VkDeviceCreateInfo-pNext-06532",
589 "If the pNext chain includes a VkPhysicalDeviceVulkan13Features structure, then it must not include a "
590 "VkPhysicalDeviceDynamicRenderingFeatures, VkPhysicalDeviceImageRobustnessFeatures, "
591 "VkPhysicalDeviceInlineUniformBlockFeatures, VkPhysicalDeviceMaintenance4Features, "
592 "VkPhysicalDevicePipelineCreationCacheControlFeatures, VkPhysicalDevicePrivateDataFeatures, "
593 "VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures, VkPhysicalDeviceShaderIntegerDotProductFeatures, "
594 "VkPhysicalDeviceShaderTerminateInvocationFeatures, VkPhysicalDeviceSubgroupSizeControlFeatures, "
595 "VkPhysicalDeviceSynchronization2Features, VkPhysicalDeviceTextureCompressionASTCHDRFeatures, or "
596 "VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures structure");
597 break;
598 }
599 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
600 }
601 }
602
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600603 // Validate pCreateInfo->pQueueCreateInfos
604 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600605
606 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700607 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
608 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600609 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700610 skip |=
611 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
612 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
613 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
614 "index value.",
615 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600616 }
617
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700618 if (queue_create_info.pQueuePriorities != nullptr) {
619 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
620 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600621 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700622 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
623 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
624 "] (=%f) is not between 0 and 1 (inclusive).",
625 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 }
627 }
628 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700629
630 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700631 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700632 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700633 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700634 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700635 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700636 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700637 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700638 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800639 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700640 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800641 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
642 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700643 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600644 }
645 }
646
sfricke-samsung30a57412020-05-15 21:14:54 -0700647 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700648 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700649 VkBool32 variable_pointers = VK_FALSE;
650 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700651 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700652 variable_pointers = vulkan_11_features->variablePointers;
653 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700654 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700655 variable_pointers = variable_pointers_features->variablePointers;
656 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700657 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700658 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700659 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
660 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
661 }
662
sfricke-samsungfd76c342020-05-29 23:13:43 -0700663 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700664 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700665 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700666 VkBool32 multiview_geometry_shader = VK_FALSE;
667 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700668 if (vulkan_11_features) {
669 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700670 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
671 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700672 } else if (multiview_features) {
673 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700674 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
675 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700676 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700677 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700678 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
679 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
680 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700681 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700682 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
683 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
684 }
685
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 return skip;
687}
688
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500689bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700690 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700691 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
692 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
693 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694 }
695
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700696 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600697}
698
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700699bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500700 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100701 bool skip = false;
702
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700704 skip |=
705 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600706
707 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
708 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
709 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
710 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
712 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
713 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 }
715
716 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
717 // queueFamilyIndexCount uint32_t values
718 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
720 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
721 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
722 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600723 }
724 }
725
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700726 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
727 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
728 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
729 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
730 }
731
732 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
733 skip |=
734 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
735 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
736 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
737 }
738
739 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
740 skip |=
741 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
742 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
743 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
744 }
745
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
747 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
748 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
749 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
751 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
752 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
Piers Daniella7f93b62021-11-20 12:32:04 -0700754
755 const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext);
756 if (maintenance4_features && maintenance4_features->maintenance4) {
757 if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) {
758 skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409",
759 "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size "
760 "VkPhysicalDeviceMaintenance4Properties.maxBufferSize");
761 }
762 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600763 }
764
765 return skip;
766}
767
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700768bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500769 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600770 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600771
772 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800773 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700774 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600775 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
776 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
777 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
778 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700779 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
780 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
781 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600782 }
783
784 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
785 // queueFamilyIndexCount uint32_t values
786 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
788 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
789 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
790 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600791 }
792 }
793
Dave Houlton413a6782018-05-22 13:01:54 -0600794 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700795 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600796 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600798 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700799 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600800
Dave Houlton413a6782018-05-22 13:01:54 -0600801 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700802 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600803 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700804 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600805
Dave Houlton130c0212018-01-29 13:39:56 -0700806 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700807 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
808 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700809 skip |= LogError(
810 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600811 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
812 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700813 }
814
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600815 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100816 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
817 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700818 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
819 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
820 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600821 }
822
823 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700824 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100825 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700826 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
827 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
828 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
829 ") are not equal.",
830 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100831 }
832
833 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700834 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
835 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
836 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
837 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100838 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600839 }
840
841 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700842 skip |= LogError(
843 device, "VUID-VkImageCreateInfo-imageType-00957",
844 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600845 }
846 }
847
Dave Houlton130c0212018-01-29 13:39:56 -0700848 // 3D image may have only 1 layer
849 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700850 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
851 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700852 }
853
Dave Houlton130c0212018-01-29 13:39:56 -0700854 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
855 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
856 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
857 // At least one of the legal attachment bits must be set
858 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
860 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700861 }
862 // No flags other than the legal attachment bits may be set
863 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
864 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700865 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
866 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700867 }
868 }
869
Jeff Bolzef40fec2018-09-01 22:04:34 -0500870 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700871 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500872 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700873 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700874 ? static_cast<uint32_t>(ceil(log2(max_dim)))
875 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
876 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600877 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700878 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
879 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
880 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600881 }
882
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700883 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700884 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
885 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
886 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600887 }
888
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700889 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700890 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
891 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
892 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100893 }
894
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700895 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700896 skip |= LogError(
897 device, "VUID-VkImageCreateInfo-flags-01924",
898 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
899 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
900 }
901
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600902 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
903 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700904 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
905 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
907 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
908 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600909 }
910
911 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700912 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600913 // Linear tiling is unsupported
914 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700915 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700916 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
917 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600918 }
919
920 // Sparse 1D image isn't valid
921 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700922 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
923 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600924 }
925
926 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700927 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700928 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
929 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
930 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600931 }
932
933 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700934 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700935 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
936 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
937 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600938 }
939
940 // Multi-sample 2D image when device doesn't support it
941 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700942 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600943 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700944 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
945 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
946 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700947 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600948 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
950 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
951 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700952 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600953 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700954 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
955 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
956 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700957 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600958 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
960 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
961 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600962 }
963 }
964 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500965
Jeff Bolz9af91c52018-09-01 21:53:57 -0500966 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
967 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700968 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
969 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
970 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500971 }
972 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700973 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
974 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
975 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500976 }
977 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700978 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
979 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
980 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500981 }
982 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500983
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700984 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600985 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700986 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
987 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
988 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500989 }
990
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700991 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700992 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
993 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800994 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
995 "depth/stencil format.",
996 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500997 }
998
Dave Houlton142c4cb2018-10-17 15:04:41 -0600999 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001000 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
1001 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
1002 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
1003 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001004 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001005 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001006 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
1007 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
1008 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
1009 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -05001010 }
1011 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05001012
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001013 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -08001014 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -07001015 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
1016 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -08001017 "format (%s) must be a depth or depth/stencil format.",
1018 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -07001019 }
1020
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001021 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001022 if (image_stencil_struct != nullptr) {
1023 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
1024 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
1025 // No flags other than the legal attachment bits may be set
1026 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
1027 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001028 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
1029 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
1030 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
1031 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001032 }
1033 }
1034
sfricke-samsung61a57c02021-01-10 21:35:12 -08001035 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -05001036 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
1037 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001038 skip |=
1039 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
1040 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1041 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
1042 ") exceeds device "
1043 "maxFramebufferWidth (%" PRIu32 ")",
1044 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001045 }
1046
1047 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001048 skip |=
1049 LogError(device, "VUID-VkImageCreateInfo-format-02537",
1050 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1051 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
1052 ") exceeds device "
1053 "maxFramebufferHeight (%" PRIu32 ")",
1054 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001055 }
1056 }
1057
1058 if (!physical_device_features.shaderStorageImageMultisample &&
1059 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1060 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1061 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001062 LogError(device, "VUID-VkImageCreateInfo-format-02538",
1063 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1064 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
1065 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001066 }
1067
1068 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-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001072 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1073 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1074 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1075 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1076 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001077 skip |= LogError(
1078 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001079 "vkCreateImage(): Depth-stencil image in which usage does not include "
1080 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1081 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1082 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1083 }
1084
1085 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-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001089 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1090 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1091 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1092 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1093 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001094 skip |= LogError(
1095 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001096 "vkCreateImage(): Depth-stencil image in which usage does not include "
1097 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1098 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1099 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1100 }
1101 }
1102 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001103
1104 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1105 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1106 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1107 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1108 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1109 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001110
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001111 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001112 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001113 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1114 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001115 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1116 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1117 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1118 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1119 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1120 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1121 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001122 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001123 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1124 } else if (drm_format_mod_list != nullptr) {
1125 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1126 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1127 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001128 }
1129 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1130 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1131 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1132 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1133 "in the pNext chain");
1134 }
1135 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001136
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001137 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001138 bool image_create_maybe_linear = false;
1139 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1140 image_create_maybe_linear = true;
1141 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1142 image_create_maybe_linear = false;
1143 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1144 image_create_maybe_linear =
1145 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001146 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001147 }
1148
1149 // If multi-sample, validate type, usage, tiling and mip levels.
1150 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001151 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001152 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1153 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1154 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1155 }
1156
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001157 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001158 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1159 image_create_maybe_linear)) {
1160 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1161 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1162 }
1163
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001164 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1165 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1166 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1167 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1168 "imageType must be VK_IMAGE_TYPE_2D.");
1169 }
1170 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1171 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1172 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1173 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1174 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001175 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001176 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001177 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1178 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1179 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1180 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1181 }
1182 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1183 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1184 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1185 "imageType must be VK_IMAGE_TYPE_2D.");
1186 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001187 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001188 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1189 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1190 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1191 }
1192 if (pCreateInfo->mipLevels != 1) {
1193 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001194 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1195 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001196 pCreateInfo->mipLevels);
1197 }
1198 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001199
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001200 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001201 if (swapchain_create_info != nullptr) {
1202 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1203 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1204 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1205 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1206 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1207 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1208
1209 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1210 // also implicitly forces the check above that extent.depth is 1
1211 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1212 string_VkImageType(pCreateInfo->imageType));
1213 }
1214 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001215 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001216 pCreateInfo->mipLevels);
1217 }
1218 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1219 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1220 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1221 }
1222 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1223 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1224 base_message, string_VkImageTiling(pCreateInfo->tiling));
1225 }
1226 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1227 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1228 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1229 }
1230 const VkImageCreateFlags valid_flags =
1231 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001232 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001233 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001234 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001235 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001236 }
1237 }
1238 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001239
1240 // If Chroma subsampled format ( _420_ or _422_ )
1241 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1242 skip |=
1243 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1244 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1245 ") must be a multiple of 2.",
1246 string_VkFormat(image_format), pCreateInfo->extent.width);
1247 }
1248 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1249 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1250 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1251 ") must be a multiple of 2.",
1252 string_VkFormat(image_format), pCreateInfo->extent.height);
1253 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001254
1255 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1256 if (format_list_info) {
1257 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1258 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1259 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1260 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001261 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001262 viewFormatCount);
1263 }
1264 // Check if viewFormatCount is not zero that it is all compatible
1265 for (uint32_t i = 0; i < viewFormatCount; i++) {
Mike Schuchardtb0608492022-04-05 18:52:48 -07001266 const bool class_compatible =
1267 FormatCompatibilityClass(format_list_info->pViewFormats[i]) == FormatCompatibilityClass(image_format);
1268 if (!class_compatible) {
1269 if (image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) {
1270 const bool size_compatible =
1271 FormatIsCompressed(format_list_info->pViewFormats[i])
1272 ? false
1273 : FormatElementSize(format_list_info->pViewFormats[i]) == FormatElementSize(image_format);
1274 if (!size_compatible) {
1275 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1276 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1277 "] (%s) and VkImageCreateInfo::format (%s) are not compatible or size-compatible.",
1278 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1279 }
1280 } else {
1281 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-06722",
1282 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1283 "] (%s) and VkImageCreateInfo::format (%s) are not compatible.",
1284 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
1285 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001286 }
1287 }
1288 }
Younggwan Kimff6495a2021-12-16 20:28:45 +00001289
1290 const auto image_compression_control = LvlFindInChain<VkImageCompressionControlEXT>(pCreateInfo->pNext);
1291 if (image_compression_control) {
1292 constexpr VkImageCompressionFlagsEXT AllVkImageCompressionFlagBitsEXT =
1293 (VK_IMAGE_COMPRESSION_DEFAULT_EXT | VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT |
1294 VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT | VK_IMAGE_COMPRESSION_DISABLED_EXT);
1295 skip |= validate_flags("vkCreateImage", "VkImageCompressionControlEXT::flags", "VkImageCompressionFlagsEXT",
1296 AllVkImageCompressionFlagBitsEXT, image_compression_control->flags, kRequiredSingleBit,
1297 "VUID-VkImageCompressionControlEXT-flags-06747");
1298
1299 if (image_compression_control->flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT &&
1300 !image_compression_control->pFixedRateFlags) {
1301 skip |= LogError(
1302 device, "VUID-VkImageCompressionControlEXT-flags-06748",
1303 "VkImageCompressionControlEXT::pFixedRateFlags is nullptr even though VkImageCompressionControlEXT::flags are %s",
1304 string_VkImageCompressionFlagsEXT(image_compression_control->flags).c_str());
1305 }
1306 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001307 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001308
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001309 return skip;
1310}
1311
Jeff Bolz99e3f632020-03-24 22:59:22 -05001312bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1313 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1314 bool skip = false;
1315
1316 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001317 // Validate feature set if using CUBE_ARRAY
1318 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1319 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1320 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1321 "enabling the imageCubeArray feature.");
1322 }
1323
Jeff Bolz99e3f632020-03-24 22:59:22 -05001324 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1325 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1326 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001327 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1328 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001329 pCreateInfo->subresourceRange.layerCount);
1330 }
1331 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001332 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1333 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1334 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1335 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001336 }
1337 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001338
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001339 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001340 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001341 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1342 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1343 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1344 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1345 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1346 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1347 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001348 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1349 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001350 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1351 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1352 "not an ASTC format.",
1353 string_VkFormat(pCreateInfo->format));
1354 }
1355 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001356
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001357 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001358 if (ycbcr_conversion != nullptr) {
1359 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1360 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1361 skip |= LogError(
1362 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1363 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1364 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1365 "r swizzle = %s\n"
1366 "g swizzle = %s\n"
1367 "b swizzle = %s\n"
1368 "a swizzle = %s\n",
1369 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1370 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1371 }
1372 }
1373 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001374 }
1375 return skip;
1376}
1377
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001378bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001379 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001380 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001381
1382 // Note: for numerical correctness
1383 // - float comparisons should expect NaN (comparison always false).
1384 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1385
1386 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001387 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001388 if (v1_f <= 0.0f) return true;
1389
1390 float intpart;
1391 const float fract = modff(v1_f, &intpart);
1392
1393 assert(std::numeric_limits<float>::radix == 2);
1394 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1395 if (intpart >= u32_max_plus1) return false;
1396
1397 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001398 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001399 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001400 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001401 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001402 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001403 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001404 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001405 };
1406
1407 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1408 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1409 return (v1_f <= v2_f);
1410 };
1411
1412 // width
1413 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001414 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001415
1416 if (!(viewport.width > 0.0f)) {
1417 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001418 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1419 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001420 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1421 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001422 skip |= LogError(object, "VUID-VkViewport-width-01771",
1423 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1424 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001425 }
1426
1427 // height
1428 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001429 const bool negative_height_enabled =
1430 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001431 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001432
1433 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1434 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001435 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1436 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001437 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1438 height_healthy = false;
1439
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001440 skip |= LogError(object, "VUID-VkViewport-height-01773",
1441 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1442 ").",
1443 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001444 }
1445
1446 // x
1447 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001448 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001449 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001450 skip |= LogError(object, "VUID-VkViewport-x-01774",
1451 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1452 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001453 }
1454
1455 // x + width
1456 if (x_healthy && width_healthy) {
1457 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001458 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001459 skip |= LogError(
1460 object, "VUID-VkViewport-x-01232",
1461 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1462 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1463 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001464 }
1465 }
1466
1467 // y
1468 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001469 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001470 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001471 skip |= LogError(object, "VUID-VkViewport-y-01775",
1472 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1473 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001474 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001475 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001476 skip |= LogError(object, "VUID-VkViewport-y-01776",
1477 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1478 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001479 }
1480
1481 // y + height
1482 if (y_healthy && height_healthy) {
1483 const float boundary = viewport.y + viewport.height;
1484
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001485 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001486 skip |= LogError(object, "VUID-VkViewport-y-01233",
1487 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1488 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1489 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001490 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001491 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001492 LogError(object, "VUID-VkViewport-y-01777",
1493 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1494 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1495 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001496 }
1497 }
1498
sfricke-samsungfd06d422021-01-22 02:17:21 -08001499 // 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 -07001500 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001501 // minDepth
1502 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001503 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001504 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001505 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1506 "[0.0, 1.0] range.",
1507 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001508 }
1509
1510 // maxDepth
1511 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001512 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001514 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1515 "[0.0, 1.0] range.",
1516 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001517 }
1518 }
1519
1520 return skip;
1521}
1522
Dave Houlton142c4cb2018-10-17 15:04:41 -06001523struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001524 VkShadingRatePaletteEntryNV shadingRate;
1525 uint32_t width;
1526 uint32_t height;
1527};
1528
1529// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001530static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001531 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1532 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1533 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1534 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1535 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1536 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001537};
1538
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001539bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001540 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001541
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001542 SampleOrderInfo *sample_order_info;
1543 uint32_t info_idx = 0;
1544 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1545 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1546 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001547 break;
1548 }
1549 }
1550
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001551 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001552 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1553 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1554 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001555 return skip;
1556 }
1557
Dave Houlton142c4cb2018-10-17 15:04:41 -06001558 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001559 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001560 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1561 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1562 ") must "
1563 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1564 "is set in framebufferNoAttachmentsSampleCounts.",
1565 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001566 }
1567
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001568 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001569 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1570 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1571 ") must "
1572 "be equal to the product of sampleCount (=%" PRIu32
1573 "), the fragment width for shadingRate "
1574 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001575 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001576 }
1577
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001578 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001579 skip |= LogError(
1580 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001581 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1582 ") must "
1583 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001584 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001585 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001586
1587 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001588 // the first width*height*sampleCount bits to all be set. Note: There is no
1589 // guarantee that 64 bits is enough, but practically it's unlikely for an
1590 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001591 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001592 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001593 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001594 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1595 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001596 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1597 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001598 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001599 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001600 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1601 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001602 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001603 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001604 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1605 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001606 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001607 uint32_t idx =
1608 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1609 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001610 }
1611
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001612 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1613 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001614 skip |= LogError(
1615 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001616 "The array pSampleLocations must contain exactly one entry for "
1617 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001618 }
1619
1620 return skip;
1621}
1622
sfricke-samsung51303fb2021-05-09 19:09:13 -07001623bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1624 const VkAllocationCallbacks *pAllocator,
1625 VkPipelineLayout *pPipelineLayout) const {
1626 bool skip = false;
1627 // Validate layout count against device physical limit
1628 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1629 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001630 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1631 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001632 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1633 }
1634
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001635 const bool has_independent_sets = (pCreateInfo->flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT) != 0;
1636 const bool graphics_pipeline_library = IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library);
1637 const char *const valid_dsl_vuid = (!graphics_pipeline_library)
1638 ? "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561"
1639 : ((!has_independent_sets) ? "VUID-VkPipelineLayoutCreateInfo-flags-06562" : nullptr);
1640 if (valid_dsl_vuid) {
1641 for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
1642 if (!pCreateInfo->pSetLayouts[i]) {
1643 skip |=
1644 LogError(device, valid_dsl_vuid, "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32 "] is VK_NULL_HANDLE.", i);
1645 }
1646 }
1647 }
1648
sfricke-samsung51303fb2021-05-09 19:09:13 -07001649 // Validate Push Constant ranges
1650 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1651 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1652 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1653 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1654 // Check that offset + size don't exceed the max.
1655 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1656 if (offset >= max_push_constants_size) {
1657 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001658 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1659 ") that exceeds this "
1660 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001661 i, offset, max_push_constants_size);
1662 }
1663 if (size > max_push_constants_size - offset) {
1664 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001665 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1666 ") and size (%" PRIu32
1667 ") "
1668 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001669 i, offset, size, max_push_constants_size);
1670 }
1671
1672 // size needs to be non-zero and a multiple of 4.
1673 if (size == 0) {
1674 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001675 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1676 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001677 i, size);
1678 }
1679 if (size & 0x3) {
1680 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001681 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1682 ") is not a multiple of 4.",
1683 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001684 }
1685
1686 // offset needs to be a multiple of 4.
1687 if ((offset & 0x3) != 0) {
1688 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001689 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1690 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001691 i, offset);
1692 }
1693 }
1694
1695 // 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.
1696 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1697 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1698 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001699 skip |=
1700 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1701 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001702 }
1703 }
1704 }
1705 return skip;
1706}
1707
ziga-lunargc6341372021-07-28 12:57:42 +02001708bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1709 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1710 bool skip = false;
1711
1712 const auto *required_subgroup_size_features =
1713 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1714
1715 if (required_subgroup_size_features) {
1716 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1717 skip |= LogError(
1718 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1719 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1720 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1721 func_name, msg, pCreateInfo->flags);
1722 }
1723 }
1724
1725 return skip;
1726}
1727
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001728bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1729 uint32_t createInfoCount,
1730 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1731 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001732 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001733 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001734
1735 if (pCreateInfos != nullptr) {
1736 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001737 bool has_dynamic_viewport = false;
1738 bool has_dynamic_scissor = false;
1739 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001740 bool has_dynamic_depth_bias = false;
1741 bool has_dynamic_blend_constant = false;
1742 bool has_dynamic_depth_bounds = false;
1743 bool has_dynamic_stencil_compare = false;
1744 bool has_dynamic_stencil_write = false;
1745 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001746 bool has_dynamic_viewport_w_scaling_nv = false;
1747 bool has_dynamic_discard_rectangle_ext = false;
1748 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001749 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001750 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001751 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001752 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001753 bool has_dynamic_cull_mode = false;
1754 bool has_dynamic_front_face = false;
1755 bool has_dynamic_primitive_topology = false;
1756 bool has_dynamic_viewport_with_count = false;
1757 bool has_dynamic_scissor_with_count = false;
1758 bool has_dynamic_vertex_input_binding_stride = false;
1759 bool has_dynamic_depth_test_enable = false;
1760 bool has_dynamic_depth_write_enable = false;
1761 bool has_dynamic_depth_compare_op = false;
1762 bool has_dynamic_depth_bounds_test_enable = false;
1763 bool has_dynamic_stencil_test_enable = false;
1764 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001765 bool has_patch_control_points = false;
1766 bool has_rasterizer_discard_enable = false;
1767 bool has_depth_bias_enable = false;
1768 bool has_logic_op = false;
1769 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001770 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001771
1772 // Create a copy of create_info and set non-included sub-state to null
1773 auto create_info = pCreateInfos[i];
1774 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1775 if (graphics_lib_info) {
Nathaniel Cesariobcb79682022-03-31 21:13:52 -06001776 // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries
1777 if (enabled[gpu_validation]) {
1778 skip |=
1779 LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported");
1780 }
1781 if (enabled[gpu_validation]) {
1782 skip |= LogError(device, kVUIDUndefined,
1783 "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported");
1784 }
1785
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001786 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1787 create_info.pVertexInputState = nullptr;
1788 create_info.pInputAssemblyState = nullptr;
1789 }
1790 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1791 create_info.pViewportState = nullptr;
1792 create_info.pRasterizationState = nullptr;
1793 create_info.pTessellationState = nullptr;
1794 }
1795 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1796 create_info.pDepthStencilState = nullptr;
1797 }
1798 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1799 create_info.pColorBlendState = nullptr;
1800 }
1801 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1802 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1803 create_info.pMultisampleState = nullptr;
1804 }
1805 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1806 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1807 create_info.layout = VK_NULL_HANDLE;
1808 }
1809 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1810 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1811 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1812 create_info.renderPass = VK_NULL_HANDLE;
1813 create_info.subpass = 0;
1814 }
1815 }
1816
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001817 if (!create_info.renderPass) {
1818 if (create_info.pColorBlendState && create_info.pMultisampleState) {
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001819 const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext);
ziga-lunarg97584c32022-04-22 14:33:37 +02001820 // Pipeline has fragment output state
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001821 if (rendering_struct) {
1822 if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1823 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1824 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1825 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001826
1827 if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) {
1828 skip |= LogError(
1829 device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587",
1830 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1831 "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.",
1832 i, string_VkFormat(rendering_struct->depthAttachmentFormat));
1833 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001834 }
1835
1836 if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1837 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1838 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1839 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001840 if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) {
Nathaniel Cesario1ba7ca52022-04-18 12:35:00 -06001841 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588",
1842 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1843 "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a "
1844 "stencil aspect.",
1845 i, string_VkFormat(rendering_struct->stencilAttachmentFormat));
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001846 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001847 }
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001848
1849 if (rendering_struct->colorAttachmentCount != 0) {
1850 skip |= validate_ranged_enum_array(
1851 "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579",
1852 "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums,
1853 rendering_struct->colorAttachmentCount, rendering_struct->pColorAttachmentFormats, true, true);
1854 }
ziga-lunarg97584c32022-04-22 14:33:37 +02001855
1856 if (rendering_struct->pColorAttachmentFormats) {
1857 for (uint32_t j = 0; j < rendering_struct->colorAttachmentCount; ++j) {
1858 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "pColorAttachmentFormats", "VkFormat",
1859 AllVkFormatEnums, rendering_struct->pColorAttachmentFormats[j],
1860 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
1861 }
1862 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001863 }
ziga-lunarg47258542022-04-22 17:40:43 +02001864
1865 // VkAttachmentSampleCountInfoAMD == VkAttachmentSampleCountInfoNV
1866 auto attachment_sample_count_info = LvlFindInChain<VkAttachmentSampleCountInfoAMD>(create_info.pNext);
1867 if (attachment_sample_count_info && attachment_sample_count_info->pColorAttachmentSamples) {
1868 for (uint32_t j = 0; j < attachment_sample_count_info->colorAttachmentCount; ++j) {
1869 skip |= validate_flags("vkCreateGraphicsPipelines",
1870 ParameterName("VkAttachmentSampleCountInfoAMD->pColorAttachmentSamples"),
1871 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
1872 attachment_sample_count_info->pColorAttachmentSamples[j], kRequiredFlags,
1873 "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
1874 }
1875 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001876 }
1877 }
1878
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001879 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1880 if (create_info.stageCount == 0) {
1881 skip |=
1882 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1883 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1884 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1885 }
1886 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1887 // ParameterName::IndexFormatSpecifier
1888 skip |= validate_struct_type_array(
1889 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1890 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
1891 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages,
1892 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1893 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06001894 "VUID-VkGraphicsPipelineCreateInfo-pStages-06600");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001895 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1896 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1897 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
1898 pCreateInfos[i].pRasterizationState,
1899 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1900 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1901 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001902 }
1903
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001904 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1905 if (create_info.pDynamicState != nullptr) {
1906 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001907 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1908 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001909 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1910 if (has_dynamic_viewport == true) {
1911 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1912 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001913 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001914 i);
1915 }
1916 has_dynamic_viewport = true;
1917 }
1918 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1919 if (has_dynamic_scissor == true) {
1920 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1921 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001922 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001923 i);
1924 }
1925 has_dynamic_scissor = true;
1926 }
1927 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1928 if (has_dynamic_line_width == true) {
1929 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1930 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001931 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001932 i);
1933 }
1934 has_dynamic_line_width = true;
1935 }
1936 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1937 if (has_dynamic_depth_bias == true) {
1938 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1939 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001940 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001941 i);
1942 }
1943 has_dynamic_depth_bias = true;
1944 }
1945 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1946 if (has_dynamic_blend_constant == true) {
1947 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1948 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001949 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001950 i);
1951 }
1952 has_dynamic_blend_constant = true;
1953 }
1954 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1955 if (has_dynamic_depth_bounds == true) {
1956 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1957 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001958 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001959 i);
1960 }
1961 has_dynamic_depth_bounds = true;
1962 }
1963 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1964 if (has_dynamic_stencil_compare == true) {
1965 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1966 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001967 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001968 i);
1969 }
1970 has_dynamic_stencil_compare = true;
1971 }
1972 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1973 if (has_dynamic_stencil_write == true) {
1974 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1975 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001976 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001977 i);
1978 }
1979 has_dynamic_stencil_write = true;
1980 }
1981 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1982 if (has_dynamic_stencil_reference == true) {
1983 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1984 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001985 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001986 i);
1987 }
1988 has_dynamic_stencil_reference = true;
1989 }
1990 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1991 if (has_dynamic_viewport_w_scaling_nv == true) {
1992 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1993 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001994 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001995 i);
1996 }
1997 has_dynamic_viewport_w_scaling_nv = true;
1998 }
1999 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
2000 if (has_dynamic_discard_rectangle_ext == true) {
2001 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2002 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002003 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002004 i);
2005 }
2006 has_dynamic_discard_rectangle_ext = true;
2007 }
2008 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
2009 if (has_dynamic_sample_locations_ext == true) {
2010 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2011 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002012 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002013 i);
2014 }
2015 has_dynamic_sample_locations_ext = true;
2016 }
2017 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
2018 if (has_dynamic_exclusive_scissor_nv == true) {
2019 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2020 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002021 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002022 i);
2023 }
2024 has_dynamic_exclusive_scissor_nv = true;
2025 }
2026 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
2027 if (has_dynamic_shading_rate_palette_nv == true) {
2028 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2029 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002030 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002031 i);
2032 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06002033 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07002034 }
2035 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
2036 if (has_dynamic_viewport_course_sample_order_nv == true) {
2037 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2038 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002039 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002040 i);
2041 }
2042 has_dynamic_viewport_course_sample_order_nv = true;
2043 }
2044 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
2045 if (has_dynamic_line_stipple == true) {
2046 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2047 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002048 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002049 i);
2050 }
2051 has_dynamic_line_stipple = true;
2052 }
Piers Daniell39842ee2020-07-10 16:42:33 -06002053 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
2054 if (has_dynamic_cull_mode) {
2055 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2056 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002057 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002058 i);
2059 }
2060 has_dynamic_cull_mode = true;
2061 }
2062 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
2063 if (has_dynamic_front_face) {
2064 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2065 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_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_front_face = true;
2070 }
2071 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
2072 if (has_dynamic_primitive_topology) {
2073 skip |= LogError(
2074 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2075 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_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_primitive_topology = true;
2080 }
2081 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2082 if (has_dynamic_viewport_with_count) {
2083 skip |= LogError(
2084 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2085 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_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_viewport_with_count = true;
2090 }
2091 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2092 if (has_dynamic_scissor_with_count) {
2093 skip |= LogError(
2094 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2095 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was 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_scissor_with_count = true;
2100 }
2101 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2102 if (has_dynamic_vertex_input_binding_stride) {
2103 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2104 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2105 "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_vertex_input_binding_stride = true;
2110 }
2111 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2112 if (has_dynamic_depth_test_enable) {
2113 skip |= LogError(
2114 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2115 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_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_test_enable = true;
2120 }
2121 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2122 if (has_dynamic_depth_write_enable) {
2123 skip |= LogError(
2124 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2125 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_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_write_enable = true;
2130 }
2131 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2132 if (has_dynamic_depth_compare_op) {
2133 skip |=
2134 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2135 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_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_compare_op = true;
2140 }
2141 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2142 if (has_dynamic_depth_bounds_test_enable) {
2143 skip |= LogError(
2144 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2145 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_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_depth_bounds_test_enable = true;
2150 }
2151 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2152 if (has_dynamic_stencil_test_enable) {
2153 skip |= LogError(
2154 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2155 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002156 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002157 i);
2158 }
2159 has_dynamic_stencil_test_enable = true;
2160 }
2161 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2162 if (has_dynamic_stencil_op) {
2163 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2164 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002165 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002166 i);
2167 }
2168 has_dynamic_stencil_op = true;
2169 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002170 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2171 // Not allowed for graphics pipelines
2172 skip |= LogError(
2173 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2174 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002175 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2176 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002177 i, state_index);
2178 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002179 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2180 if (has_patch_control_points) {
2181 skip |= LogError(
2182 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2183 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_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_patch_control_points = true;
2188 }
2189 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2190 if (has_rasterizer_discard_enable) {
2191 skip |= LogError(
2192 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2193 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_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_rasterizer_discard_enable = true;
2198 }
2199 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2200 if (has_depth_bias_enable) {
2201 skip |= LogError(
2202 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2203 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002204 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002205 i);
2206 }
2207 has_depth_bias_enable = true;
2208 }
2209 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2210 if (has_logic_op) {
2211 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2212 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_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_logic_op = true;
2217 }
2218 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2219 if (has_primitive_restart_enable) {
2220 skip |= LogError(
2221 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2222 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002223 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002224 i);
2225 }
2226 has_primitive_restart_enable = true;
2227 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002228 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2229 if (has_dynamic_vertex_input) {
2230 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002231 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2232 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2233 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002234 }
2235 has_dynamic_vertex_input = true;
2236 }
Petr Kraus299ba622017-11-24 03:09:03 +01002237 }
2238 }
2239
sfricke-samsung3b944422021-01-23 02:15:19 -08002240 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2241 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2242 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002243 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2244 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002245 i);
2246 }
2247
2248 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2249 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2250 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002251 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002252 i);
2253 }
2254
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002255 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2256 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002257 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002258 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2259 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2260 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002261 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002262 }
2263
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002264 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002265
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002266 // Collect active stages and other information
2267 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002268 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002269 bool has_eval = false;
2270 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002271 if (create_info.pStages != nullptr) {
2272 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2273 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002274
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002275 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002276 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002277 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002278 has_eval = true;
2279 }
2280
Tony-LunarGd29cc032022-05-13 14:38:27 -06002281 skip |= validate_required_pointer(
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002282 "vkCreateGraphicsPipelines",
Tony-LunarGd29cc032022-05-13 14:38:27 -06002283 ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}),
2284 create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter");
2285
2286 if (create_info.pStages[stage_index].pName) {
2287 skip |= validate_string(
2288 "vkCreateGraphicsPipelines",
2289 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2290 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
2291 }
ziga-lunargc6341372021-07-28 12:57:42 +02002292
2293 std::stringstream msg;
2294 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2295 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002296 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002297 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002298 }
2299
2300 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002301 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2302 skip |=
2303 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2304 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2305 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2306 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002307
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002308 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002309 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2310
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002311 skip |= validate_struct_pnext(
2312 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002313 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002314 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2315 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2316 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2317 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002318
2319 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002320 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002321 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2322 }
2323
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002324 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002325 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2326 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002327 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002328 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2329 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2330
2331 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002332 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002333 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002334
2335 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002336 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002337 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2338
2339 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2340 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002341 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002342 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2343
2344 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002345 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002346 }
2347
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002348 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2349 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002350
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002351 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002352 skip |=
2353 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2354 "vkCreateGraphicsPipelines: pararameter "
2355 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2356 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002357 }
2358
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002359 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002360 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002361 skip |=
2362 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2363 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2364 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2365 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2366 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002367 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2368 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002369 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002370 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2371 skip |=
2372 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2373 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002374 create_info.pVertexInputState->vertexBindingDescriptionCount,
2375 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002376 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2377
2378 skip |= validate_array(
2379 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2380 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2381 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2382 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2383
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002384 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002385 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002386 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002387 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002388 skip |= validate_ranged_enum(
2389 "vkCreateGraphicsPipelines",
2390 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2391 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002392 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002393 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2394 }
2395 }
2396
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002397 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002398 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002399 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002400 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002401 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002402 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002403 skip |= validate_ranged_enum(
2404 "vkCreateGraphicsPipelines",
2405 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2406 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002407 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002408 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002409 if (FormatIsDepthOrStencil(format)) {
2410 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2411 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2412 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2413 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002414 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2415 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002416 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2417 "alignment, replace with a color format.",
2418 i, vertex_attribute_description_index, string_VkFormat(format));
2419 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002420 }
2421 }
2422
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002423 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002424 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2425 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002426 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2427 ") is "
2428 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002429 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002430 }
2431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002432 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002433 skip |=
2434 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2435 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002436 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2437 ") is "
2438 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002440 }
2441
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002442 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002443 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2444 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002445 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2446 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002447 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2448 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002449 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2450 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002451 "(%" PRIu32 ") is not distinct.",
2452 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002453 }
2454 vertex_bindings.insert(vertex_bind_desc.binding);
2455
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002456 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002457 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2458 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002459 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2460 "].binding (%" PRIu32
2461 ") is "
2462 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002463 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 }
2465
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002466 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002467 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2468 "vkCreateGraphicsPipelines: parameter "
2469 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2470 "].stride (%" PRIu32
2471 ") is greater "
2472 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2473 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002474 }
2475 }
2476
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002477 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002478 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2479 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002480 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2481 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002482 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2483 "vkCreateGraphicsPipelines: parameter "
2484 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2485 "].location (%" PRIu32 ") is not distinct.",
2486 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002487 }
2488 attribute_locations.insert(vertex_attrib_desc.location);
2489
2490 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2491 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002492 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2493 "vkCreateGraphicsPipelines: parameter "
2494 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2495 "].binding (%" PRIu32
2496 ") does not exist "
2497 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2498 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002499 }
2500
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002501 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002502 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2503 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002504 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2505 "].location (%" PRIu32
2506 ") is "
2507 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509 }
2510
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002511 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002512 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2513 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002514 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2515 "].binding (%" PRIu32
2516 ") is "
2517 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002518 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002519 }
2520
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002521 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2523 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002524 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2525 "].offset (%" PRIu32
2526 ") is "
2527 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002528 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002529 }
2530 }
2531 }
2532
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002533 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2534 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002535 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002536 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002537 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2538 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002539 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002540 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002541 i, i);
2542 } else {
2543 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2544 skip |= validate_struct_pnext(
2545 "vkCreateGraphicsPipelines",
2546 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002547 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002548 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2549 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002550
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002551 skip |= validate_reserved_flags(
2552 "vkCreateGraphicsPipelines",
2553 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002554 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002555
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002556 if (create_info.pTessellationState->patchControlPoints == 0 ||
2557 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2558 skip |=
2559 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2560 "vkCreateGraphicsPipelines: invalid parameter "
2561 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2562 ". patchControlPoints "
2563 "should be >0 and <=%" PRIu32 ".",
2564 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002565 }
2566 }
2567 }
2568
2569 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002570 if ((create_info.pRasterizationState != nullptr) &&
2571 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2572 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002573 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2574 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2575 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2576 "].pViewportState (=NULL) is not a valid pointer.",
2577 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002578 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002579 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002580
2581 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002582 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2583 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2584 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2585 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586 }
2587
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002588 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002589 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002590 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2591 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002592 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2593 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002594 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002595 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002597 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002598 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002599 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002600 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002601 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002602 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002603 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002604 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002605 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606
2607 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002608 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002609 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002610 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002611
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002612 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002613 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002614 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002615 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002616 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002617 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2618 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002619 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002620 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2621 const auto depth_clip_control_struct =
2622 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002623
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002624 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002625 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002626 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2627 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2628 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2629 ") is not 1.",
2630 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002631 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002633 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002634 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2635 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2636 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2637 ") is not 1.",
2638 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002640
Dave Houlton142c4cb2018-10-17 15:04:41 -06002641 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2642 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002643 skip |= LogError(
2644 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2645 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2646 "disabled, but pCreateInfos[%" PRIu32
2647 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2648 ") is not 1.",
2649 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002650 }
2651
Jeff Bolz9af91c52018-09-01 21:53:57 -05002652 if (shading_rate_image_struct &&
2653 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002654 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2655 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2656 "disabled, but pCreateInfos[%" PRIu32
2657 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2658 ") is neither 0 nor 1.",
2659 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002660 }
2661
Petr Krausa6103552017-11-16 21:21:58 +01002662 } else { // multiViewport enabled
2663 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002664 if (!has_dynamic_viewport_with_count) {
2665 skip |= LogError(
2666 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2667 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2668 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002669 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002670 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2671 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2672 "].pViewportState->viewportCount (=%" PRIu32
2673 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2674 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002675 } else if (has_dynamic_viewport_with_count) {
2676 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2677 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2678 "].pViewportState->viewportCount (=%" PRIu32
2679 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2680 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002681 }
Petr Krausa6103552017-11-16 21:21:58 +01002682
2683 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002684 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002685 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2686 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2687 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002688 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002689 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002690 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2691 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002692 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002693 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2694 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2695 "].pViewportState->scissorCount (=%" PRIu32
2696 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2697 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002698 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002699 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2700 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2701 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2702 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002703 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2704 "].pViewportState->scissorCount (=%" PRIu32
2705 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2706 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002707 }
2708 }
2709
ziga-lunarg845883b2021-07-14 15:05:00 +02002710 if (!has_dynamic_scissor && viewport_state.pScissors) {
2711 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2712 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002713
2714 if (scissor.offset.x < 0) {
2715 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2716 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2717 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2718 scissor.offset.x, i, scissor_i);
2719 }
2720
2721 if (scissor.offset.y < 0) {
2722 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2723 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2724 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2725 scissor.offset.y, i, scissor_i);
2726 }
2727
ziga-lunarg845883b2021-07-14 15:05:00 +02002728 const int64_t x_sum =
2729 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2730 if (x_sum > std::numeric_limits<int32_t>::max()) {
2731 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2732 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2733 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2734 "] will overflow int32_t.",
2735 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2736 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002737
ziga-lunarg845883b2021-07-14 15:05:00 +02002738 const int64_t y_sum =
2739 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2740 if (y_sum > std::numeric_limits<int32_t>::max()) {
2741 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2742 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2743 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2744 "] will overflow int32_t.",
2745 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2746 }
2747 }
2748 }
2749
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002750 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002751 skip |=
2752 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2753 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2754 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2755 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002756 }
2757
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002758 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002759 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2760 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2761 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2762 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2763 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002764 }
2765
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002766 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2767 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2768 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2769 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2770 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2771 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2772 skip |= LogError(
2773 device, vuid,
2774 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2775 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2776 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2777 }
Petr Krausa6103552017-11-16 21:21:58 +01002778 }
2779
Dave Houlton142c4cb2018-10-17 15:04:41 -06002780 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002781 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 skip |=
2783 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2784 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2785 ") must be zero or identical to pCreateInfos[%" PRIu32
2786 "].pViewportState->viewportCount (=%" PRIu32 ").",
2787 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002788 }
2789
Dave Houlton142c4cb2018-10-17 15:04:41 -06002790 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002791 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002792 skip |= LogError(
2793 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002794 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2795 "] "
2796 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2797 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2798 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002799 }
2800
Petr Krausa6103552017-11-16 21:21:58 +01002801 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002802 skip |= LogError(
2803 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002804 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2805 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002806 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2807 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002808 }
2809
2810 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002811 skip |= LogError(
2812 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002813 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2814 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002815 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2816 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002817 }
2818
Jeff Bolz3e71f782018-08-29 23:15:45 -05002819 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002820 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2821 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2822 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002823 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002824 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2825 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2826 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2827 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002828 }
2829
Jeff Bolz9af91c52018-09-01 21:53:57 -05002830 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002831 shading_rate_image_struct->viewportCount > 0 &&
2832 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002833 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002834 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002835 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002836 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2837 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002838 i, i);
2839 }
2840
Chris Mayer328d8212018-12-11 14:16:18 +01002841 if (vp_swizzle_struct) {
2842 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002843 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2844 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2845 " does "
2846 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2847 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002848 }
2849 }
2850
Petr Krausb3fcdb42018-01-09 22:09:09 +01002851 // validate the VkViewports
2852 if (!has_dynamic_viewport && viewport_state.pViewports) {
2853 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2854 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002855 const char *fn_name = "vkCreateGraphicsPipelines";
2856 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2857 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2858 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002859 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002860 }
2861 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002862
sfricke-samsung45996a42021-09-16 13:45:27 -07002863 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002864 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2865 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2866 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2867 "VK_NV_clip_space_w_scaling extension is not enabled.",
2868 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002869 }
2870
sfricke-samsung45996a42021-09-16 13:45:27 -07002871 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002872 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2873 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2874 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2875 "VK_EXT_discard_rectangles extension is not enabled.",
2876 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002877 }
2878
sfricke-samsung45996a42021-09-16 13:45:27 -07002879 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002880 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2881 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2882 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2883 "VK_EXT_sample_locations extension is not enabled.",
2884 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002885 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002886
sfricke-samsung45996a42021-09-16 13:45:27 -07002887 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002888 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2889 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2890 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2891 "VK_NV_scissor_exclusive extension is not enabled.",
2892 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002893 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002894
2895 if (coarse_sample_order_struct &&
2896 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2897 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002898 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2899 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2900 "] "
2901 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2902 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2903 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002904 }
2905
2906 if (coarse_sample_order_struct) {
2907 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002908 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002909 }
2910 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002911
2912 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2913 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002914 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2915 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2916 "] "
2917 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2918 ") "
2919 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2920 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002921 }
2922 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002923 skip |= LogError(
2924 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002925 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2926 "] "
2927 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2928 i);
2929 }
2930 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002931
2932 if (depth_clip_control_struct) {
2933 const auto *depth_clip_control_features =
2934 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2935 const bool enabled_depth_clip_control =
2936 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2937 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2938 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2939 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2940 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2941 "depthClipControl feature is not enabled. ",
2942 i);
2943 }
2944 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002945 }
2946
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002947 const bool is_frag_out_graphics_lib =
2948 graphics_lib_info &&
2949 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002950 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002951 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002952 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2953 "].pRasterizationState->rasterizerDiscardEnable "
2954 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002955 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002957 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002958 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002959 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2960 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002961 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002962 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002963 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002965 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002966 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002967 skip |= validate_struct_pnext(
2968 "vkCreateGraphicsPipelines",
2969 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002970 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002971 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2972 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002974 skip |= validate_reserved_flags(
2975 "vkCreateGraphicsPipelines",
2976 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002977 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002978
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002979 skip |= validate_bool32(
2980 "vkCreateGraphicsPipelines",
2981 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002982 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002984 skip |= validate_array(
2985 "vkCreateGraphicsPipelines",
2986 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2987 ParameterName::IndexVector{i}),
2988 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002989 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2990 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002991
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002992 skip |= validate_flags("vkCreateGraphicsPipelines",
2993 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2994 ParameterName::IndexVector{i}),
2995 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002996 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002997 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002999 skip |= validate_bool32("vkCreateGraphicsPipelines",
3000 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
3001 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003002 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003004 skip |= validate_bool32(
3005 "vkCreateGraphicsPipelines",
3006 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003007 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003008
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003009 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003010 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
3011 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3012 "].pMultisampleState->sType must be "
3013 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003014 i);
John Zulauf7acac592017-11-06 11:15:53 -07003015 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003016 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003017 if (!physical_device_features.sampleRateShading) {
3018 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
3019 "vkCreateGraphicsPipelines(): parameter "
3020 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
3021 i);
3022 }
3023 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
3024 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003025 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003026 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003027
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003028 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
3029 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
3030 "].pMultisampleState->minSampleShading.",
3031 i);
3032 }
John Zulauf7acac592017-11-06 11:15:53 -07003033 }
3034 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003035
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003036 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003037 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003038
3039 if (line_state) {
3040 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
3041 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003042 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003043 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003044 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3045 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003046 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003047 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003048 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003049 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003050 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003051 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3052 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003053 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003054 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003055 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003056 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003057 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3059 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003060 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003061 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003062 }
3063 }
3064 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3065 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3066 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003067 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003068 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3069 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003070 "range [1,256].",
3071 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003072 }
3073 }
3074 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003075 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003076 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3077 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003078 skip |=
3079 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003080 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3081 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003082 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3083 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003084 }
3085 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3086 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003087 skip |=
3088 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003089 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3090 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003091 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3092 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003093 }
3094 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3095 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003096 skip |=
3097 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
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_SMOOTH_EXT requires the smoothLines feature.",
3101 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003102 }
3103 if (line_state->stippledLineEnable) {
3104 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3105 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003106 skip |=
3107 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
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_RECTANGULAR_EXT with stipple requires the "
3111 "stippledRectangularLines feature.",
3112 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003113 }
3114 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3115 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003116 skip |=
3117 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
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_BRESENHAM_EXT with stipple requires the "
3121 "stippledBresenhamLines feature.",
3122 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003123 }
3124 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3125 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003126 skip |=
3127 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
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_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3131 "stippledSmoothLines feature.",
3132 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003133 }
3134 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003135 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 skip |=
3137 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003138 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3139 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003140 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3141 "stippledRectangularLines and strictLines features.",
3142 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003143 }
3144 }
3145 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003146 }
3147
Petr Krause91f7a12017-12-14 20:57:36 +01003148 bool uses_color_attachment = false;
3149 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003150 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003151 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003152 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003153 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003154 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003155 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003156 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003157 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003158 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003159 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003160 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003161 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003162 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003163 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003164 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003165 }
3166
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003167 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003169 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003171 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003172 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173
Mike Schuchardt00e81452021-11-29 11:11:20 -08003174 skip |=
3175 validate_flags("vkCreateGraphicsPipelines",
3176 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3177 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003178 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003179 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003180
3181 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003182 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003184 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003185
3186 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003187 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003188 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003189 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190
3191 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003192 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003194 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003195 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003196
3197 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003198 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003199 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003200 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003201
3202 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003203 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003204 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003205 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003206
3207 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003208 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003210 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003211 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003212
3213 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003214 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003216 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003217 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218
3219 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003220 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003222 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003223 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224
3225 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003226 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003227 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003228 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003229 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003230
3231 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003232 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003234 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003235 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003236
3237 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003238 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003240 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003241 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242
3243 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003244 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003245 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003246 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003247 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003248
3249 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003250 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003251 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003252 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003253 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003254
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003255 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003256 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003257 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3258 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003259 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3260 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003261 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003262
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003263 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003264 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3265 const auto *rasterization_order_attachment_access_feature =
3266 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3267 const bool rasterization_order_depth_attachment_access_feature_enabled =
3268 rasterization_order_attachment_access_feature &&
3269 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3270 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3271 skip |= LogError(
3272 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3273 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3274 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3275 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003276 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003277 }
3278
3279 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3280 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003281 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003282 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3283 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003284 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003285 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3286 }
3287 }
3288
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003289 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003290 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3291 const auto *rasterization_order_attachment_access_feature =
3292 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3293 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3294 rasterization_order_attachment_access_feature &&
3295 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3296 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3297 skip |= LogError(
3298 device,
3299 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3300 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3301 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3302 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003303 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003304 }
3305
3306 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3307 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003308 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003309 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3310 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003311 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003312 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3313 }
3314 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003315 }
3316
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003317 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003318 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3319 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003320
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003321 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3322 skip |=
3323 validate_struct_type("vkCreateGraphicsPipelines",
3324 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3325 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3326 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3327 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003328
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003329 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003330 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003331 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003332 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3333 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003334 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003335 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3336 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003337
Mike Schuchardt00e81452021-11-29 11:11:20 -08003338 skip |= validate_flags("vkCreateGraphicsPipelines",
3339 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3340 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003341 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003342 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003343
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003344 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003345 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3346 const auto *rasterization_order_attachment_access_feature =
3347 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3348 const bool rasterization_order_color_attachment_access_feature_enabled =
3349 rasterization_order_attachment_access_feature &&
3350 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3351
3352 if (!rasterization_order_color_attachment_access_feature_enabled) {
3353 skip |= LogError(
3354 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3355 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3356 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3357 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003358 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003359 }
3360
3361 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003362 skip |=
3363 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3364 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3365 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3366 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3367 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003368 }
3369 }
3370
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003371 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003372 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003373 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003374 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003375
3376 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003377 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003378 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3379 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003380 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3381 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003383 if (create_info.pColorBlendState->pAttachments != NULL) {
3384 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003385 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003386 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003387 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003388 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003389 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003390
3391 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003392 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003393 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003394 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003396 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003397 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003398
3399 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003400 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003401 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003402 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003403 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003404 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003405 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003406
3407 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003408 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003409 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003410 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003411 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003412 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003413 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003414
3415 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003416 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003417 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003418 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003419 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003420 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003421 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003422
3423 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003424 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003425 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003426 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003428 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003429 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430
3431 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003432 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003434 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003436 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003437 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438
3439 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003440 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003441 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003442 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003443 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003444 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003445 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003446
3447 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3448 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003449 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003450 case VK_BLEND_OP_ZERO_EXT:
3451 case VK_BLEND_OP_SRC_EXT:
3452 case VK_BLEND_OP_DST_EXT:
3453 case VK_BLEND_OP_SRC_OVER_EXT:
3454 case VK_BLEND_OP_DST_OVER_EXT:
3455 case VK_BLEND_OP_SRC_IN_EXT:
3456 case VK_BLEND_OP_DST_IN_EXT:
3457 case VK_BLEND_OP_SRC_OUT_EXT:
3458 case VK_BLEND_OP_DST_OUT_EXT:
3459 case VK_BLEND_OP_SRC_ATOP_EXT:
3460 case VK_BLEND_OP_DST_ATOP_EXT:
3461 case VK_BLEND_OP_XOR_EXT:
3462 case VK_BLEND_OP_INVERT_EXT:
3463 case VK_BLEND_OP_INVERT_RGB_EXT:
3464 case VK_BLEND_OP_LINEARDODGE_EXT:
3465 case VK_BLEND_OP_LINEARBURN_EXT:
3466 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3467 case VK_BLEND_OP_LINEARLIGHT_EXT:
3468 case VK_BLEND_OP_PINLIGHT_EXT:
3469 case VK_BLEND_OP_HARDMIX_EXT:
3470 case VK_BLEND_OP_PLUS_EXT:
3471 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3472 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3473 case VK_BLEND_OP_PLUS_DARKER_EXT:
3474 case VK_BLEND_OP_MINUS_EXT:
3475 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3476 case VK_BLEND_OP_CONTRAST_EXT:
3477 case VK_BLEND_OP_INVERT_OVG_EXT:
3478 case VK_BLEND_OP_RED_EXT:
3479 case VK_BLEND_OP_GREEN_EXT:
3480 case VK_BLEND_OP_BLUE_EXT:
3481 invalid = true;
3482 break;
3483 default:
3484 break;
3485 }
3486 if (invalid) {
3487 skip |= LogError(
3488 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3489 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3490 "].pColorBlendState->pAttachments[%" PRIu32
3491 "].colorBlendOp (%s) is not valid when "
3492 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3493 "VK_FALSE",
3494 i, attachment_index,
3495 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003496 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003497 }
3498 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003499 }
3500 }
3501
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003502 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003503 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003504 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3505 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003506 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3507 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003508 }
3509
3510 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003511 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003512 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003513 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003514 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003515 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003516 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003517 }
3518 }
3519 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003520
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003521 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003522 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003523 if (create_info.basePipelineIndex != -1) {
3524 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003525 skip |=
3526 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003527 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3528 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003529 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003530 "and pCreateInfos->basePipelineIndex is not -1.",
3531 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003532 }
3533 }
3534
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003535 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3536 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003537 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003538 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3539 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003540 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003541 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3542 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003543 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003544 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003545 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003546 skip |=
3547 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003548 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3549 ") must be a valid"
3550 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003551 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003552 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003553 }
3554 }
3555
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003556 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003557 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003558 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003559 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003560 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3561 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3562 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3563 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003564 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003565 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003566 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003567 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003568 "pCreateInfos[%" PRIu32
3569 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003570 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3571 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003572 }
3573 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003574 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3575 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003576 (physical_device_features.fillModeNonSolid == false)) {
3577 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003578 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3579 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003580 "pCreateInfos[%" PRIu32
3581 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003582 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3583 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003584 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003585 }
Petr Kraus299ba622017-11-24 03:09:03 +01003586
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003587 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003588 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003589 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3590 "The line width state is static (pCreateInfos[%" PRIu32
3591 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3592 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3593 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003594 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003595 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003596 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003597
3598 // Validate no flags not allowed are used
3599 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003600 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003601 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3602 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003603 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3604 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003605 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003606 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3607 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003608 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003609 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3610 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003611 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3612 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003613 }
3614 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3615 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003616 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3617 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003618 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3619 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003620 }
3621 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3622 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003623 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3624 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003625 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3626 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003627 }
3628 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3629 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003630 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3631 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003632 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3633 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003634 }
3635 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3636 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003637 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3638 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003639 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3640 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003641 }
3642 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3643 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003644 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3645 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003646 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3647 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003648 }
3649 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3650 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003651 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3652 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003653 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3654 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003655 }
3656 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3657 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003658 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3659 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003660 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3661 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003662 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003663 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3664 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3665 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3666 "]->flags (0x%x) must not include "
3667 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3668 i, flags);
3669 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003670 }
3671 }
3672
3673 return skip;
3674}
3675
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003676bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3677 uint32_t createInfoCount,
3678 const VkComputePipelineCreateInfo *pCreateInfos,
3679 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003680 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003681 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003682 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003683 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003684 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003685 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003686 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003687 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3688 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003689 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003690 skip |= LogError(
3691 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3692 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3693 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3694 feedback_count, i);
3695 }
Peter Chen85366392019-05-14 15:20:11 -04003696 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003697
3698 // Make sure compute stage is selected
3699 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003700 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003701 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3702 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003703 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003704 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003705
sfricke-samsungeb549012021-04-16 01:25:51 -07003706 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3707 // Validate no flags not allowed are used
3708 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003709 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3710 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3711 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3712 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003713 }
3714 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3715 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003716 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3717 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003718 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3719 i, flags);
3720 }
3721 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3722 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003723 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3724 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003725 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3726 i, flags);
3727 }
3728 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3729 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003730 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3731 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003732 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3733 i, flags);
3734 }
3735 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3736 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003737 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3738 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003739 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3740 i, flags);
3741 }
3742 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3743 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003744 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3745 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003746 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3747 i, flags);
3748 }
3749 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3750 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003751 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3752 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003753 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3754 i, flags);
3755 }
3756 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3757 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003758 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3759 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003760 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3761 i, flags);
3762 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003763 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3764 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003765 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3766 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003767 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3768 i, flags);
3769 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003770 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3771 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003772 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3773 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003774 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3775 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003776 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003777 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3778 if (pCreateInfos[i].basePipelineIndex != -1) {
3779 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3780 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3781 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3782 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3783 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3784 i);
3785 }
3786 }
3787
3788 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3789 if (pCreateInfos[i].basePipelineIndex != -1) {
3790 skip |= LogError(
3791 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3792 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3793 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3794 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3795 i);
3796 }
3797 } else {
3798 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3799 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3800 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3801 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3802 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3803 }
3804 }
3805 }
ziga-lunargc6341372021-07-28 12:57:42 +02003806
3807 std::stringstream msg;
3808 msg << "pCreateInfos[%" << i << "].stage";
3809 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003810 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003811 return skip;
3812}
3813
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003814bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003815 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003816 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003817
3818 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003819 const auto &features = physical_device_features;
3820 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003821
John Zulauf71968502017-10-26 13:51:15 -06003822 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3823 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003824 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3825 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3826 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3827 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003828 }
3829
3830 // Anistropy cannot be enabled in sampler unless enabled as a feature
3831 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003832 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3833 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3834 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003835 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003836 }
John Zulauf71968502017-10-26 13:51:15 -06003837
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003838 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3839 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003840 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3841 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3842 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3843 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003844 }
3845 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003846 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3847 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3848 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3849 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003850 }
3851 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003852 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3853 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3854 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3855 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003856 }
3857 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3858 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3859 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3860 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003861 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3862 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3863 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3864 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3865 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3866 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003867 }
3868 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003869 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3870 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3871 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003872 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003873 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003874 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3875 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3876 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003877 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003878 }
3879
3880 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003881 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003882 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003883 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3884 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003885 if (sampler_reduction != nullptr) {
3886 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003887 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3888 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
3889 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003890 }
3891 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003892 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003893 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003894 if (!IsExtEnabled(device_extensions.vk_ext_sampler_filter_minmax)) {
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003895 skip |= LogError(device, "VUID-VkSamplerCreateInfo-pNext-06726",
sjfricke751b7092022-04-12 21:49:37 +09003896 "vkCreateSampler(): sampler reduction mode is %s, but extension %s is not enabled.",
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003897 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3898 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
3899 }
ziga-lunarg01be97a2022-05-01 14:30:39 +02003900
3901 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
3902 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
3903 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
3904 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
3905 "extension %s is not enabled.",
3906 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3907 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
3908 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
3909 }
3910 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003911 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003912
3913 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3914 // valid VkBorderColor value
3915 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3916 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3917 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003918 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3919 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003920 }
3921
John Zulauf275805c2017-10-26 15:34:49 -06003922 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003923 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003924 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3925 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003926 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3927 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3928 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003929 }
3930 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003931
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003932 // Check for valid Lod range
3933 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003934 skip |=
3935 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3936 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003937 }
3938
3939 // Check mipLodBias to device limit
3940 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003941 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3942 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3943 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003944 }
3945
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003946 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003947 if (sampler_conversion != nullptr) {
3948 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3949 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3950 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3951 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003952 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003953 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003954 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3955 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3956 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3957 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3958 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3959 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3960 }
3961 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003962
3963 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3964 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3965 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3966 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3967 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3968 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3969 }
3970 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3971 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3972 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3973 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3974 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3975 }
3976 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3977 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3978 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3979 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3980 pCreateInfo->minLod, pCreateInfo->maxLod);
3981 }
3982 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3983 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3984 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3985 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3986 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3987 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3988 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3989 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3990 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3991 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3992 }
3993 if (pCreateInfo->anisotropyEnable) {
3994 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3995 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3996 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3997 }
3998 if (pCreateInfo->compareEnable) {
3999 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
4000 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4001 "pCreateInfo->compareEnable must be VK_FALSE");
4002 }
4003 if (pCreateInfo->unnormalizedCoordinates) {
4004 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
4005 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4006 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
4007 }
4008 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004009
Piers Daniell833b9492021-11-20 11:47:10 -07004010 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
4011 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
4012 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
4013 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4014 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
4015 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
4016 }
4017 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
4018 if (!custom_create_info) {
4019 skip |= LogError(
4020 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
4021 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
4022 "struct in pNext chain.\n",
4023 string_VkBorderColor(pCreateInfo->borderColor));
4024 } else {
4025 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
4026 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
4027 !FormatIsSampledInt(custom_create_info->format)) ||
4028 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
4029 !FormatIsSampledFloat(custom_create_info->format)))) {
4030 skip |=
4031 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06004032 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
4033 "whose type does not match\n",
4034 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07004035 ;
4036 }
4037 }
4038 }
4039
4040 const auto *border_color_component_mapping =
4041 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
4042 if (border_color_component_mapping) {
4043 const auto *border_color_swizzle_features =
4044 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4045 bool border_color_swizzle_features_enabled =
4046 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4047 if (!border_color_swizzle_features_enabled) {
4048 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4049 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4050 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004051 }
4052 }
4053 }
4054
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004055 return skip;
4056}
4057
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004058bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
4059 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4060 const char *func_name) const {
4061 bool skip = false;
4062
4063 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4064 uint32_t mutable_type_count = 0;
4065 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4066 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4067 }
4068 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4069 if (mutable_type_count == 0) {
4070 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4071 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4072 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4073 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4074 "].descriptorTypeCount is 0.",
4075 func_name, i, i);
4076 }
4077 } else {
4078 if (mutable_type_count > 0) {
4079 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4080 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4081 "].descriptorType is %s, but "
4082 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4083 "].descriptorTypeCount is not 0.",
4084 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4085 }
4086 }
4087 }
4088
4089 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4090 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4091 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
4092 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4093 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4094 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4095 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4096 func_name, j, k);
4097 break;
4098 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4099 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4100 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4101 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4102 func_name, j, k);
4103 break;
4104 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4105 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4106 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4107 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4108 func_name, j, k);
4109 break;
4110 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4111 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4112 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4113 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4114 func_name, j, k);
4115 break;
4116 default:
4117 break;
4118 }
4119 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4120 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4121 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4122 skip |=
4123 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4124 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4125 "].pDescriptorTypes[%" PRIu32
4126 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4127 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4128 func_name, j, k, j, l,
4129 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4130 }
4131 }
4132 }
4133 }
4134
4135 return skip;
4136}
4137
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004138bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4139 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4140 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004141 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004142 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004143
ziga-lunargfc6896f2021-10-15 18:46:12 +02004144 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4145 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4146 bool mutable_descriptor_type_features_enabled =
4147 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4148
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004149 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4150 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4151 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4152 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004153 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4154 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4155 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4156 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4157 ++descriptor_index) {
4158 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004159 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004160 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004161 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4162 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004163 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004164 }
4165 }
4166 }
4167
4168 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4169 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4170 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004171 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004172 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4173 "].descriptorCount is not 0, "
4174 "pCreateInfo->pBindings[%" PRIu32
4175 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004176 "values.",
4177 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004178 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004179
4180 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4181 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4182 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004183 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4184 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4185 "].descriptorCount is not 0 and "
4186 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4187 "].stageFlags "
4188 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4189 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004190 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004191
4192 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4193 if (!mutable_descriptor_type) {
4194 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4195 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4196 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4197 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4198 i);
4199 }
4200 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4201 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4202 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4203 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4204 "pImmutableSamplers is not NULL.",
4205 i);
4206 }
4207 if (!mutable_descriptor_type_features_enabled) {
4208 skip |= LogError(
4209 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4210 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4211 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4212 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4213 i);
4214 }
4215 }
4216
4217 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4218 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4219 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4220 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4221 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4222 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4223 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004224 }
4225 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004226
4227 if (mutable_descriptor_type) {
4228 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4229 "vkDescriptorSetLayoutCreateInfo");
4230 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004231 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004232 if (pCreateInfo) {
4233 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4234 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4235 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4236 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4237 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4238 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4239 }
4240 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4241 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4242 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4243 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4244 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4245 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4246 }
4247 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4248 !mutable_descriptor_type_features_enabled) {
4249 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4250 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4251 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4252 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4253 }
4254 }
4255
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004256 return skip;
4257}
4258
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004259bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4260 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004261 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004262 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4263 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4264 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004265 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4266 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004267}
4268
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004269bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4270 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004271 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004272 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004273
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004274 if (pDescriptorWrites != NULL) {
4275 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4276 // descriptorCount must be greater than 0
4277 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004278 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4279 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4280 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004281 }
4282
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004283 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004284 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004285 // dstSet must be a valid VkDescriptorSet handle
4286 skip |= validate_required_handle(vkCallingFunction,
4287 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4288 pDescriptorWrites[i].dstSet);
4289 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004290
4291 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4292 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4293 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4294 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4295 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004296 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004297 if (!isPushDescriptor) {
4298 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4299 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4300 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4301 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4302 // ObjectLifetimes::ValidateDescriptorWrite.
4303 skip |= LogError(
4304 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4305 "%s(): if pDescriptorWrites[%" PRIu32
4306 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4307 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4308 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4309 vkCallingFunction, i, i);
4310 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4311 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4312 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4313 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4314 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4315 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4316 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4317 "%s(): if pDescriptorWrites[%" PRIu32
4318 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4319 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4320 "].pImageInfo must not be NULL.",
4321 vkCallingFunction, i, i);
4322 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004323 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4324 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004325 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4326 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004327 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4328 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004329 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004330 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4331 ParameterName::IndexVector{i, descriptor_index}),
4332 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004333 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004334 }
4335 }
4336 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4337 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4338 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4339 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4340 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4341 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4342 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004343 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004344 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004345 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004346 "%s(): if pDescriptorWrites[%" PRIu32
4347 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004348 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4349 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004350 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004351 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004352 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004353 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004354 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004355 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004356 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4357 ++descriptor_index) {
4358 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4359 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4360 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004361 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004362 "%s(): if pDescriptorWrites[%" PRIu32
4363 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004364 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004365 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4366 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004367 }
4368 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004369 }
4370 }
4371 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4372 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004373 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004374 }
4375
4376 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4377 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004378 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004379 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4380 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004381 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004382 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004383 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004384 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004385 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004386 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004387 }
4388 }
4389 }
4390 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4391 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004392 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004393 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4394 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004395 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004396 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004398 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004399 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004400 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004401 }
4402 }
4403 }
4404 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004405 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4406 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004407 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004408 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004409 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4410 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4411 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4412 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004413 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004414 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4415 pDescriptorWrites[i].descriptorCount);
4416 }
4417 // further checks only if we have right structtype
4418 if (pnext_struct) {
4419 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4420 skip |= LogError(
4421 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004422 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4423 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004424 ".",
4425 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004426 }
sourav parmarbcee7512020-12-28 14:34:49 -08004427 if (pnext_struct->accelerationStructureCount == 0) {
4428 skip |= LogError(device,
4429 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004430 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004431 }
4432 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004433 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004434 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4435 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4436 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4437 skip |= LogError(device,
4438 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4439 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004440 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004441 }
4442 }
4443 }
sourav parmarbcee7512020-12-28 14:34:49 -08004444 }
4445 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004446 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004447 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4448 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4449 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4450 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004451 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004452 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4453 pDescriptorWrites[i].descriptorCount);
4454 }
4455 // further checks only if we have right structtype
4456 if (pnext_struct) {
4457 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4458 skip |= LogError(
4459 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004460 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4461 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004462 ".",
4463 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004464 }
sourav parmarbcee7512020-12-28 14:34:49 -08004465 if (pnext_struct->accelerationStructureCount == 0) {
4466 skip |= LogError(device,
4467 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004468 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004469 }
4470 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004471 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004472 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4473 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4474 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4475 skip |= LogError(device,
4476 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4477 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004478 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004479 }
4480 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004481 }
4482 }
4483 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004484 }
4485 }
4486 return skip;
4487}
4488
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004489bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4490 const VkWriteDescriptorSet *pDescriptorWrites,
4491 uint32_t descriptorCopyCount,
4492 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004493 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004494}
4495
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004496bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004497 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004498 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004499 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4500}
4501
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004502bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4503 const VkAllocationCallbacks *pAllocator,
4504 VkRenderPass *pRenderPass) const {
4505 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4506}
4507
Mike Schuchardt2df08912020-12-15 16:28:09 -08004508bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004509 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004510 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004511 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4512}
4513
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004514bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4515 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004516 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004517 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004518
4519 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4520 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4521 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004522 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4523 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004524 return skip;
4525}
4526
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004527bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004528 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004529 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004530
4531 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4532 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004533 bool cb_is_secondary;
4534 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004535 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004536 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4537 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004538
Tony-LunarG3c287f62020-12-17 12:39:49 -07004539 if (cb_is_secondary) {
4540 // Implicit VUs
4541 // validate only sType here; pointer has to be validated in core_validation
4542 const bool k_not_required = false;
4543 const char *k_no_vuid = nullptr;
4544 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4545 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004546 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4547 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004548
Tony-LunarG3c287f62020-12-17 12:39:49 -07004549 if (info) {
4550 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004551 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004552 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4553 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004554 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004555 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004556 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4557 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4558 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4559 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004560
Tony-LunarG3c287f62020-12-17 12:39:49 -07004561 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004562
Tony-LunarG3c287f62020-12-17 12:39:49 -07004563 // Explicit VUs
4564 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004565 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004566 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4567 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4568 cmd_name);
4569 }
4570
4571 if (physical_device_features.inheritedQueries) {
4572 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004573 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4574 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4575 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004576 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004577 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004578 }
4579
4580 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004581 skip |=
4582 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4583 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4584 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4585 } else { // !pipelineStatisticsQuery
4586 skip |=
4587 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4588 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004589 }
4590
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004591 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004592 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004593 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004594 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4595 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4596 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004597 commandBuffer,
4598 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004599 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4600 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4601 }
Petr Kraus139757b2019-08-15 17:19:33 +02004602 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004603
4604 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4605 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4606 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4607 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4608 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4609 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4610 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4611 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4612 }
Petr Kraus139757b2019-08-15 17:19:33 +02004613 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004614 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004615 return skip;
4616}
4617
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004618bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004619 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004620 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004621
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004622 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004623 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004624 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4625 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4626 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004627 }
4628 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004629 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4630 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4631 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004632 }
4633 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004634 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004635 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004636 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4637 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4638 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4639 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004640 }
4641 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004642
4643 if (pViewports) {
4644 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4645 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004646 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004647 skip |= manual_PreCallValidateViewport(
4648 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004649 }
4650 }
4651
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004652 return skip;
4653}
4654
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004655bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004656 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004657 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004658
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004659 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004660 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004661 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4662 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4663 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004664 }
4665 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004666 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4667 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4668 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004669 }
4670 } else { // multiViewport enabled
4671 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004672 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004673 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4674 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4675 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4676 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004677 }
4678 }
4679
Petr Kraus6260f0a2018-02-27 21:15:55 +01004680 if (pScissors) {
4681 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4682 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004683
Petr Kraus6260f0a2018-02-27 21:15:55 +01004684 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004685 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4686 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4687 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004688 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004689
Petr Kraus6260f0a2018-02-27 21:15:55 +01004690 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004691 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4692 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4693 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004694 }
4695
4696 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4697 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004698 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4699 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4700 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4701 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004702 }
4703
4704 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4705 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004706 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4707 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4708 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4709 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004710 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004711 }
4712 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004713
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004714 return skip;
4715}
4716
Jeff Bolz5c801d12019-10-09 10:38:45 -05004717bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004718 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004719
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004720 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004721 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4722 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004723 }
4724
4725 return skip;
4726}
4727
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004728bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004729 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004730 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004731
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004732 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004733 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004734 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4735 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004736 }
4737 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004738 skip |=
4739 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4740 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4741 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004742 }
4743 return skip;
4744}
4745
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004746bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004747 VkDeviceSize offset, uint32_t drawCount,
4748 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004749 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004750 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004751 skip |=
4752 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4753 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4754 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004755 }
4756 if (drawCount > device_limits.maxDrawIndirectCount) {
4757 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004758 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4759 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004760 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004761 }
4762 return skip;
4763}
4764
sfricke-samsungf692b972020-05-02 08:00:45 -07004765bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4766 VkDeviceSize countBufferOffset, bool khr) const {
4767 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004768 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004769 if (offset & 3) {
4770 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004771 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004772 }
4773
4774 if (countBufferOffset & 3) {
4775 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004776 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004777 countBufferOffset);
4778 }
4779 return skip;
4780}
4781
4782bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4783 VkDeviceSize offset, VkBuffer countBuffer,
4784 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4785 uint32_t stride) const {
4786 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4787}
4788
4789bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4790 VkDeviceSize offset, VkBuffer countBuffer,
4791 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4792 uint32_t stride) const {
4793 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4794}
4795
4796bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4797 VkDeviceSize countBufferOffset, bool khr) const {
4798 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004799 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004800 if (offset & 3) {
4801 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004802 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004803 }
4804
4805 if (countBufferOffset & 3) {
4806 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004807 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004808 countBufferOffset);
4809 }
4810 return skip;
4811}
4812
4813bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4814 VkDeviceSize offset, VkBuffer countBuffer,
4815 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4816 uint32_t stride) const {
4817 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4818}
4819
4820bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4821 VkDeviceSize offset, VkBuffer countBuffer,
4822 VkDeviceSize countBufferOffset,
4823 uint32_t maxDrawCount, uint32_t stride) const {
4824 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4825}
4826
Tony-LunarG4490de42021-06-21 15:49:19 -06004827bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4828 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4829 uint32_t firstInstance, uint32_t stride) const {
4830 bool skip = false;
4831 if (stride & 3) {
4832 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4833 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4834 }
4835 if (drawCount && nullptr == pVertexInfo) {
4836 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4837 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4838 "one or more valid instances of VkMultiDrawInfoEXT structures");
4839 }
4840 return skip;
4841}
4842
4843bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4844 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4845 uint32_t instanceCount, uint32_t firstInstance,
4846 uint32_t stride, const int32_t *pVertexOffset) const {
4847 bool skip = false;
4848 if (stride & 3) {
4849 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4850 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4851 }
4852 if (drawCount && nullptr == pIndexInfo) {
4853 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4854 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4855 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4856 }
4857 return skip;
4858}
4859
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004860bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4861 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004862 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004863 bool skip = false;
4864 for (uint32_t rect = 0; rect < rectCount; rect++) {
4865 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004866 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004867 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004868 }
sfricke-samsung10867682020-04-25 02:20:39 -07004869 if (pRects[rect].rect.extent.width == 0) {
4870 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004871 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004872 }
4873 if (pRects[rect].rect.extent.height == 0) {
4874 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004875 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004876 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004877 }
4878 return skip;
4879}
4880
Andrew Fobel3abeb992020-01-20 16:33:22 -05004881bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4882 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4883 VkImageFormatProperties2 *pImageFormatProperties,
4884 const char *apiName) const {
4885 bool skip = false;
4886
4887 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004888 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004889 if (image_stencil_struct != nullptr) {
4890 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4891 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4892 // No flags other than the legal attachment bits may be set
4893 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4894 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004895 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4896 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4897 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4898 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4899 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004900 }
4901 }
4902 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004903 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4904 if (image_drm_format) {
4905 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4906 skip |= LogError(
4907 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4908 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4909 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4910 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4911 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004912 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4913 skip |= LogError(
4914 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4915 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4916 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4917 apiName, image_drm_format->queueFamilyIndexCount);
4918 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004919 } else {
4920 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4921 skip |= LogError(
4922 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4923 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4924 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4925 apiName);
4926 }
4927 }
4928 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4929 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4930 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4931 if (!format_list || format_list->viewFormatCount == 0) {
4932 skip |= LogError(
4933 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4934 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4935 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4936 apiName);
4937 }
4938 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004939 }
4940
4941 return skip;
4942}
4943
4944bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4945 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4946 VkImageFormatProperties2 *pImageFormatProperties) const {
4947 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4948 "vkGetPhysicalDeviceImageFormatProperties2");
4949}
4950
4951bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4952 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4953 VkImageFormatProperties2 *pImageFormatProperties) const {
4954 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4955 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4956}
4957
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004958bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4959 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4960 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4961 bool skip = false;
4962
4963 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4964 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4965 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4966 }
4967
4968 return skip;
4969}
4970
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004971bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4972 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4973 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4974 bool skip = false;
4975
4976 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4977 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4978 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4979 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4980 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4981 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4982 }
4983
ziga-lunarg42f884b2021-08-25 16:13:20 +02004984 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004985}
4986
sfricke-samsung3999ef62020-02-09 17:05:59 -08004987bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4988 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4989 bool skip = false;
4990
4991 if (pRegions != nullptr) {
4992 for (uint32_t i = 0; i < regionCount; i++) {
4993 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004994 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004995 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004996 }
4997 }
4998 }
4999 return skip;
5000}
5001
Jeff Leger178b1e52020-10-05 12:22:23 -04005002bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
5003 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
5004 bool skip = false;
5005
5006 if (pCopyBufferInfo->pRegions != nullptr) {
5007 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5008 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06005009 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005010 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04005011 }
5012 }
5013 }
5014 return skip;
5015}
5016
Tony-LunarGef035472021-11-02 10:23:33 -06005017bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
5018 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
5019 bool skip = false;
5020
5021 if (pCopyBufferInfo->pRegions != nullptr) {
5022 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5023 if (pCopyBufferInfo->pRegions[i].size == 0) {
5024 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
5025 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
5026 }
5027 }
5028 }
5029 return skip;
5030}
5031
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005032bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005033 VkDeviceSize dstOffset, VkDeviceSize dataSize,
5034 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005035 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005036
5037 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005038 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5039 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5040 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005041 }
5042
5043 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005044 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5045 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5046 "), must be greater than zero and less than or equal to 65536.",
5047 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005048 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005049 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5050 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5051 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005052 }
5053 return skip;
5054}
5055
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005056bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005057 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005058 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005059
5060 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005061 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5062 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5063 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005064 }
5065
5066 if (size != VK_WHOLE_SIZE) {
5067 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005068 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005069 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5070 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005071 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005072 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5073 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005074 }
5075 }
5076 return skip;
5077}
5078
sfricke-samsunga1d00272021-03-10 21:37:41 -08005079bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005080 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005081
5082 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005083 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5084 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5085 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5086 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005087 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005088 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5089 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5090 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005091 }
5092
5093 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5094 // queueFamilyIndexCount uint32_t values
5095 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005096 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005097 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005098 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005099 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5100 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005101 }
5102 }
5103
Dave Houlton413a6782018-05-22 13:01:54 -06005104 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005105 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005106
sfricke-samsunga1d00272021-03-10 21:37:41 -08005107 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5108 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5109 if (format_list_info) {
5110 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5111 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5112 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5113 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005114 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5115 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005116 func_name, viewFormatCount);
5117 }
5118
5119 // Using the first format, compare the rest of the formats against it that they are compatible
5120 for (uint32_t i = 1; i < viewFormatCount; i++) {
5121 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5122 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5123 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5124 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005125 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5126 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005127 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5128 string_VkFormat(format_list_info->pViewFormats[i]));
5129 }
5130 }
5131 }
5132
5133 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5134 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5135 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5136 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5137 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5138 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5139 func_name);
5140 } else {
5141 if (format_list_info == nullptr) {
5142 skip |= LogError(
5143 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5144 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5145 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5146 func_name);
5147 } else if (format_list_info->viewFormatCount == 0) {
5148 skip |= LogError(
5149 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5150 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5151 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5152 func_name);
5153 } else {
5154 bool found_base_format = false;
5155 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5156 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5157 found_base_format = true;
5158 break;
5159 }
5160 }
5161 if (!found_base_format) {
5162 skip |=
5163 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5164 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5165 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5166 "pCreateInfo->imageFormat.",
5167 func_name);
5168 }
5169 }
5170 }
5171 }
5172 }
5173 return skip;
5174}
5175
5176bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5177 const VkAllocationCallbacks *pAllocator,
5178 VkSwapchainKHR *pSwapchain) const {
5179 bool skip = false;
5180 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5181 return skip;
5182}
5183
5184bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5185 const VkSwapchainCreateInfoKHR *pCreateInfos,
5186 const VkAllocationCallbacks *pAllocator,
5187 VkSwapchainKHR *pSwapchains) const {
5188 bool skip = false;
5189 if (pCreateInfos) {
5190 for (uint32_t i = 0; i < swapchainCount; i++) {
5191 std::stringstream func_name;
5192 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5193 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5194 }
5195 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005196 return skip;
5197}
5198
Jeff Bolz5c801d12019-10-09 10:38:45 -05005199bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005200 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005201
5202 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005203 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005204 if (present_regions) {
5205 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005206 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005207 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5208 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005209 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005210 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5211 "extension swapchainCount is %i. These values must be equal.",
5212 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005213 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005214 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005215 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5216 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005217 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5218 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5219 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005220 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005221 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005222 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005223 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005224 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005225 }
5226 }
5227
5228 return skip;
5229}
5230
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005231bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5232 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5233 const VkAllocationCallbacks *pAllocator,
5234 VkDisplayModeKHR *pMode) const {
5235 bool skip = false;
5236
5237 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5238 if (display_mode_parameters.visibleRegion.width == 0) {
5239 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5240 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5241 }
5242 if (display_mode_parameters.visibleRegion.height == 0) {
5243 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5244 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5245 }
5246 if (display_mode_parameters.refreshRate == 0) {
5247 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5248 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5249 }
5250
5251 return skip;
5252}
5253
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005254#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005255bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5256 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5257 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005258 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005259 bool skip = false;
5260
5261 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005262 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5263 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005264 }
5265
5266 return skip;
5267}
5268#endif // VK_USE_PLATFORM_WIN32_KHR
5269
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005270static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5271 bool partial_overlap = false;
5272
5273 static const std::vector<VkDescriptorType> all_descriptor_types = {
5274 VK_DESCRIPTOR_TYPE_SAMPLER,
5275 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5276 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5277 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5278 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5279 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5280 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5281 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5282 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5283 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5284 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5285 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5286 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5287 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5288 };
5289
5290 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5291 if (mutable_descriptor_type) {
5292 std::vector<VkDescriptorType> first_types, second_types;
5293 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5294 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5295 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5296 }
5297 } else {
5298 first_types = all_descriptor_types;
5299 }
5300 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5301 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5302 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5303 }
5304 } else {
5305 second_types = all_descriptor_types;
5306 }
5307
5308 bool complete_overlap = first_types.size() == second_types.size();
5309 bool disjoint = true;
5310 for (const auto first_type : first_types) {
5311 bool found = false;
5312 for (const auto second_type : second_types) {
5313 if (first_type == second_type) {
5314 found = true;
5315 break;
5316 }
5317 }
5318 if (found) {
5319 disjoint = false;
5320 } else {
5321 complete_overlap = false;
5322 }
5323 if (!disjoint && !complete_overlap) {
5324 partial_overlap = true;
5325 break;
5326 }
5327 }
5328 }
5329
5330 return partial_overlap;
5331}
5332
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005333bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005334 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005335 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005336 bool skip = false;
5337
5338 if (pCreateInfo) {
5339 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005340 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5341 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005342 }
5343
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005344 const auto *mutable_descriptor_type_features =
5345 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5346 bool mutable_descriptor_type_enabled =
5347 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5348
Petr Krausc8655be2017-09-27 18:56:51 +02005349 if (pCreateInfo->pPoolSizes) {
5350 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5351 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005352 skip |= LogError(
5353 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005354 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005355 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005356 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5357 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005358 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5359 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5360 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5361 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5362 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005363 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005364 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5365 skip |=
5366 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5367 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5368 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5369 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5370 i);
5371 }
5372 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5373 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5374 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5375 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5376 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5377 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5378 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5379 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5380 " and have sets which partially overlap.",
5381 i, j);
5382 }
5383 }
5384 }
5385 }
Petr Krausc8655be2017-09-27 18:56:51 +02005386 }
5387 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005388
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005389 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5390 skip |=
5391 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5392 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5393 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5394 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005395 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5396 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5397 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5398 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5399 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5400 }
Petr Krausc8655be2017-09-27 18:56:51 +02005401 }
5402
5403 return skip;
5404}
5405
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005406bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005407 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005408 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005409
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005410 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005411 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005412 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5413 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5414 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005415 }
5416
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005417 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005418 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005419 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5420 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5421 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005422 }
5423
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005424 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005425 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005426 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5427 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5428 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005429 }
5430
5431 return skip;
5432}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005433
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005434bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005435 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005436 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005437
5438 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005439 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5440 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005441 }
5442 return skip;
5443}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005444
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005445bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5446 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005447 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005448 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005449
5450 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005451 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005452 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005453 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5454 "vkCmdDispatch(): baseGroupX (%" PRIu32
5455 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5456 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005457 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005458 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5459 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5460 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5461 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005462 }
5463
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005464 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005465 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005466 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5467 "vkCmdDispatch(): baseGroupY (%" PRIu32
5468 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5469 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005470 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005471 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5472 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5473 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5474 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005475 }
5476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005477 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005478 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005479 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5480 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5481 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5482 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005483 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005484 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5485 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5486 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5487 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005488 }
5489
5490 return skip;
5491}
5492
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005493bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5494 VkPipelineBindPoint pipelineBindPoint,
5495 VkPipelineLayout layout, uint32_t set,
5496 uint32_t descriptorWriteCount,
5497 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005498 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005499}
5500
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005501bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5502 uint32_t firstExclusiveScissor,
5503 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005504 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005505 bool skip = false;
5506
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005507 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005508 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005509 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005510 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5511 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5512 ") is not 0.",
5513 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005514 }
5515 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005516 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005517 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5518 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5519 ") is not 1.",
5520 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005521 }
5522 } else { // multiViewport enabled
5523 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005524 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005525 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5526 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5527 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5528 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005529 }
5530 }
5531
Jeff Bolz3e71f782018-08-29 23:15:45 -05005532 if (pExclusiveScissors) {
5533 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5534 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5535
5536 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005537 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5538 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5539 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005540 }
5541
5542 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005543 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5544 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5545 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005546 }
5547
5548 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5549 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005550 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5551 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5552 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5553 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005554 }
5555
5556 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5557 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005558 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5559 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5560 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5561 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005562 }
5563 }
5564 }
5565
5566 return skip;
5567}
5568
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005569bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5570 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005571 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005572 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005573 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5574 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5575 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5576 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5577 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5578 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005579 }
5580
5581 return skip;
5582}
5583
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005584bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5585 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005586 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005587 bool skip = false;
5588
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005589 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005590 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005591 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005592 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5593 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5594 ") is not 0.",
5595 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005596 }
5597 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005598 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005599 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5600 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5601 ") is not 1.",
5602 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005603 }
5604 }
5605
Jeff Bolz9af91c52018-09-01 21:53:57 -05005606 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005607 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005608 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5609 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5610 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5611 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005612 }
5613
5614 return skip;
5615}
5616
Jeff Bolz5c801d12019-10-09 10:38:45 -05005617bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5618 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5619 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005620 bool skip = false;
5621
Dave Houlton142c4cb2018-10-17 15:04:41 -06005622 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005623 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5624 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5625 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005626 }
5627
5628 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005629 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005630 }
5631
5632 return skip;
5633}
5634
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005635bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005636 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005637 bool skip = false;
5638
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005639 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005640 skip |= LogError(
5641 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005642 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5643 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005644 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005645 }
5646
5647 return skip;
5648}
5649
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005650bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5651 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005652 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005653 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005654 static const int condition_multiples = 0b0011;
5655 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005656 skip |= LogError(
5657 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005658 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005659 }
Lockee1c22882019-06-10 16:02:54 -06005660 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005661 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5662 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5663 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5664 stride);
Lockee1c22882019-06-10 16:02:54 -06005665 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005666 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005667 skip |= LogError(
5668 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005669 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5670 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005671 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005672 if (drawCount > device_limits.maxDrawIndirectCount) {
5673 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005674 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5675 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005676 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005677 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005678 return skip;
5679}
5680
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005681bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5682 VkDeviceSize offset, VkBuffer countBuffer,
5683 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005684 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005685 bool skip = false;
5686
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005687 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005688 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5689 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5690 "), is not a multiple of 4.",
5691 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005692 }
5693
5694 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005695 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5696 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5697 "), is not a multiple of 4.",
5698 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005699 }
5700
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005701 return skip;
5702}
5703
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005704bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005705 const VkAllocationCallbacks *pAllocator,
5706 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005707 bool skip = false;
5708
5709 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5710 if (pCreateInfo != nullptr) {
5711 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5712 // VkQueryPipelineStatisticFlagBits values
5713 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5714 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005715 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5716 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5717 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5718 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005719 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005720 if (pCreateInfo->queryCount == 0) {
5721 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5722 "vkCreateQueryPool(): queryCount must be greater than zero.");
5723 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005724 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005725 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005726}
5727
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005728bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5729 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005730 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005731 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5732 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005733}
5734
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005735void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005736 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5737 VkResult result) {
5738 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005739 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005740}
5741
Mike Schuchardt2df08912020-12-15 16:28:09 -08005742void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005743 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5744 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005745 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005746 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005747 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005748}
5749
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005750void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5751 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005752 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005753 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005754 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005755}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005756
Tony-LunarG3c287f62020-12-17 12:39:49 -07005757void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005758 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005759 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005760 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005761 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005762 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005763 }
5764 }
5765}
5766
5767void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005768 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005769 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005770 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5771 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5772 }
5773}
5774
5775void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005776 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005777 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005778 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5779 if (item->second == commandPool) {
5780 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005781 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005782 ++item;
5783 }
5784 }
5785}
5786
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005787bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005788 const VkAllocationCallbacks *pAllocator,
5789 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005790 bool skip = false;
5791
5792 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005793 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005794 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005795 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5796 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005797 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005798
5799 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005800 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005801 if (flags_info) {
5802 flags = flags_info->flags;
5803 }
5804
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005805 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005806 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005807 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005808 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5809 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005810 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005811 }
5812
5813#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005814 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005815#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005816 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5817 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005818#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005819 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005820#endif
5821
5822 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005823 skip |= LogError(
5824 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005825 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5826 }
5827 if (
5828#ifdef VK_USE_PLATFORM_WIN32_KHR
5829 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5830#endif
5831 (import_memory_fd && import_memory_fd->handleType) ||
5832#ifdef VK_USE_PLATFORM_ANDROID_KHR
5833 (import_memory_ahb && import_memory_ahb->buffer) ||
5834#endif
5835 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005836 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5837 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005838 }
5839 }
5840
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005841 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5842 if (export_memory) {
5843 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5844 if (export_memory_nv) {
5845 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5846 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5847 "VkExportMemoryAllocateInfoNV");
5848 }
5849#ifdef VK_USE_PLATFORM_WIN32_KHR
5850 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5851 if (export_memory_win32_nv) {
5852 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5853 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5854 "VkExportMemoryWin32HandleInfoNV");
5855 }
5856#endif
5857 }
5858
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005859 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005860 VkBool32 capture_replay = false;
5861 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005862 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005863 if (vulkan_12_features) {
5864 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5865 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5866 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005867 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005868 if (bda_features) {
5869 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5870 buffer_device_address = bda_features->bufferDeviceAddress;
5871 }
5872 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005873 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005874 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005875 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005876 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005877 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005878 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005879 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005880 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005881 }
5882 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005883 }
5884 return skip;
5885}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005886
Jason Macnak192fa0e2019-07-26 15:07:16 -07005887bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005888 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005889 bool skip = false;
5890
5891 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5892 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5893 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005894 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005895 } else {
5896 uint32_t vertex_component_size = 0;
5897 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5898 vertex_component_size = 4;
5899 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5900 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5901 vertex_component_size = 2;
5902 }
5903 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005904 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005905 }
5906 }
5907
5908 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5909 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005910 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005911 } else {
5912 uint32_t index_element_size = 0;
5913 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5914 index_element_size = 4;
5915 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5916 index_element_size = 2;
5917 }
5918 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005919 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005920 }
5921 }
5922 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5923 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005924 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005925 }
5926 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005927 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005928 }
5929 }
5930
5931 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005932 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005933 }
5934
5935 return skip;
5936}
5937
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005938bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5939 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005940 bool skip = false;
5941
5942 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005943 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005944 }
5945 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005946 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005947 }
5948
5949 return skip;
5950}
5951
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005952bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5953 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005954 bool skip = false;
5955 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005956 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005957 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005958 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005959 }
5960 return skip;
5961}
5962
5963bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005964 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005965 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005966 bool skip = false;
5967 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005968 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5969 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5970 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005971 }
5972 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005973 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5974 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5975 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005976 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005977 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5978 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5979 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5980 }
Jason Macnak5c954952019-07-09 15:46:12 -07005981 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5982 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005983 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5984 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5985 "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 -07005986 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005987 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005988 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005989 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5990 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005991 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5992 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005993 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005994 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005995 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5996 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5997 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005998 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005999 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07006000 uint64_t total_triangle_count = 0;
6001 for (uint32_t i = 0; i < info.geometryCount; i++) {
6002 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07006003
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006004 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006005
Jason Macnak5c954952019-07-09 15:46:12 -07006006 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
6007 continue;
6008 }
6009 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
6010 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006011 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006012 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
6013 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
6014 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006015 }
6016 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006017 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
6018 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
6019 for (uint32_t i = 1; i < info.geometryCount; i++) {
6020 const VkGeometryNV &geometry = info.pGeometries[i];
6021 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006022 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006023 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
6024 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006025 "info.pGeometries[0].geometryType.",
6026 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07006027 }
6028 }
6029 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006030 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
6031 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
6032 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
6033 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
6034 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
6035 "or VK_GEOMETRY_TYPE_AABBS_NV.");
6036 }
6037 }
6038 skip |=
6039 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006040 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006041 return skip;
6042}
6043
Ricardo Garciaa4935972019-02-21 17:43:18 +01006044bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6045 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006046 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006047 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006048 if (pCreateInfo) {
6049 if ((pCreateInfo->compactedSize != 0) &&
6050 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006051 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6052 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6053 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6054 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006055 }
Jason Macnak5c954952019-07-09 15:46:12 -07006056
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006057 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006058 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006059 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006060 return skip;
6061}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006062
Jeff Bolz5c801d12019-10-09 10:38:45 -05006063bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6064 const VkAccelerationStructureInfoNV *pInfo,
6065 VkBuffer instanceData, VkDeviceSize instanceOffset,
6066 VkBool32 update, VkAccelerationStructureNV dst,
6067 VkAccelerationStructureNV src, VkBuffer scratch,
6068 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006069 bool skip = false;
6070
6071 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006072 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006073 }
6074
6075 return skip;
6076}
6077
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006078bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6079 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6080 VkAccelerationStructureKHR *pAccelerationStructure) const {
6081 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006082 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006083 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006084 if (!acceleration_structure_features ||
6085 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6086 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6087 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6088 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006089 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006090 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6091 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006092 (acceleration_structure_features &&
6093 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006094 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006095 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6096 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6097 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6098 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006099 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006100 if (pCreateInfo->deviceAddress &&
6101 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6102 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6103 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6104 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6105 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006106 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6107 (acceleration_structure_features &&
6108 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6109 skip |= LogError(
6110 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6111 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6112 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6113 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006114 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6115 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006116 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6117 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006118 }
sourav parmar83c31b12020-05-06 12:30:54 -07006119 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006120 return skip;
6121}
6122
Jason Macnak5c954952019-07-09 15:46:12 -07006123bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6124 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006125 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006126 bool skip = false;
6127 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006128 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6129 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006130 }
6131 return skip;
6132}
6133
sourav parmarcd5fb182020-07-17 12:58:44 -07006134bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6135 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6136 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6137 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006138 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006139 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006140 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006141 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006142 }
6143 return skip;
6144}
6145
Peter Chen85366392019-05-14 15:20:11 -04006146bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6147 uint32_t createInfoCount,
6148 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6149 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006150 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006151 bool skip = false;
6152
6153 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006154 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6155 std::stringstream msg;
6156 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6157 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6158 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006159 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006160 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006161 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006162 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6163 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6164 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6165 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006166 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006167
6168 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006169 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006170 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6171 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6172 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6173 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6174 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6175 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6176 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6177 }
6178 }
6179
sourav parmarf4a78252020-04-10 13:04:21 -07006180 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6181 skip |=
6182 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6183 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6184 }
6185 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6186 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6187 skip |=
6188 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6189 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6190 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6191 }
6192 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6193 if (pCreateInfos[i].basePipelineIndex != -1) {
6194 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6195 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6196 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6197 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6198 "and pCreateInfos->basePipelineIndex is not -1.");
6199 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006200 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006201 skip |=
6202 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6203 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6204 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6205 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6206 "that element.");
6207 }
sourav parmarf4a78252020-04-10 13:04:21 -07006208 }
6209 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006210 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006211 skip |=
6212 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6213 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6214 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6215 "commands pCreateInfos parameter.");
6216 }
6217 } else {
6218 if (pCreateInfos[i].basePipelineIndex != -1) {
6219 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6220 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6221 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6222 }
6223 }
6224 }
6225 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6226 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6227 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6228 }
6229 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6230 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6231 "vkCreateRayTracingPipelinesNV: flags must not include "
6232 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6233 }
6234 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6235 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6236 "vkCreateRayTracingPipelinesNV: flags must not include "
6237 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6238 }
6239 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6240 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6241 "vkCreateRayTracingPipelinesNV: flags must not include "
6242 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6243 }
6244 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6245 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6246 "vkCreateRayTracingPipelinesNV: flags must not include "
6247 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6248 }
6249 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6250 skip |= LogError(
6251 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6252 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6253 }
6254 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6255 skip |= LogError(
6256 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6257 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6258 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006259 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6260 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6261 "vkCreateRayTracingPipelinesNV: flags must not include "
6262 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6263 }
6264 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6265 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6266 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6267 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006268 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6269 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6270 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6271 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6272 }
Peter Chen85366392019-05-14 15:20:11 -04006273 }
6274
6275 return skip;
6276}
6277
sourav parmarcd5fb182020-07-17 12:58:44 -07006278bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6279 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6280 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006281 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006282 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006283 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6284 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6285 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006286 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006287 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006288 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6289 std::stringstream msg;
6290 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6291 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006292 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006293 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006294 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6295 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6296 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6297 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6298 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6299 }
6300 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6301 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6302 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6303 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6304 }
6305 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006306 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006307 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006308 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006309 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6310 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6311 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006312 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6313 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6314 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006315 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006316 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006317 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6318 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6319 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6320 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006321 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006322 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6323 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6324 }
6325 }
sourav parmarf4a78252020-04-10 13:04:21 -07006326 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006327 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6328 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006329 }
6330 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006331 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006332 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006333 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6334 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006335 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006336 }
6337 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6338 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6339 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006340 }
6341 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6342 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6343 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6344 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6345 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6346 skip |= LogError(
6347 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006348 "vkCreateRayTracingPipelinesKHR: If flags includes "
6349 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_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 anyHitShader of that element "
6352 "must not be VK_SHADER_UNUSED_KHR");
6353 }
6354 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6355 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6356 skip |= LogError(
6357 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006358 "vkCreateRayTracingPipelinesKHR: If flags includes "
6359 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006360 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6361 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6362 "element must not be VK_SHADER_UNUSED_KHR");
6363 }
6364 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006365 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6366 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6367 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6368 skip |= LogError(
6369 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6370 "vkCreateRayTracingPipelinesKHR: If "
6371 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6372 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6373 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6374 }
6375 }
sourav parmarf4a78252020-04-10 13:04:21 -07006376 }
6377 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6378 if (pCreateInfos[i].basePipelineIndex != -1) {
6379 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6380 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006381 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006382 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6383 "and pCreateInfos->basePipelineIndex is not -1.");
6384 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006385 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006386 skip |=
6387 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6388 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6389 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6390 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6391 "element.");
6392 }
sourav parmarf4a78252020-04-10 13:04:21 -07006393 }
6394 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006395 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006396 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006397 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006398 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6399 ") must be a valid into the calling"
6400 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006401 pCreateInfos[i].basePipelineIndex, createInfoCount);
6402 }
6403 } else {
6404 if (pCreateInfos[i].basePipelineIndex != -1) {
6405 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006406 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006407 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6408 }
6409 }
6410 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006411 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6412 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6413 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6414 "vkCreateRayTracingPipelinesKHR: If flags includes "
6415 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6416 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006417 }
6418 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6419 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6420 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6421 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6422 "pLibraryInfo and pLibraryInterface must be NULL.");
6423 }
6424 if (pCreateInfos[i].pLibraryInfo) {
6425 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6426 if (pCreateInfos[i].stageCount == 0) {
6427 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6428 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6429 "stageCount must not be 0.");
6430 }
6431 if (pCreateInfos[i].groupCount == 0) {
6432 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6433 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6434 "groupCount must not be 0.");
6435 }
6436 } else {
6437 if (pCreateInfos[i].pLibraryInterface == NULL) {
6438 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6439 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6440 "is greater than 0, its "
6441 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006442 }
6443 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006444 }
6445 if (pCreateInfos[i].pLibraryInterface) {
6446 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6447 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6448 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6449 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6450 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6451 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006452 }
6453 if (deferredOperation != VK_NULL_HANDLE) {
6454 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6455 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6456 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6457 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006458 }
6459 }
ziga-lunargdea76582021-09-17 14:38:08 +02006460 if (pCreateInfos[i].pDynamicState) {
6461 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6462 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6463 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6464 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6465 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6466 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6467 }
6468 }
6469 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006470 }
6471
6472 return skip;
6473}
6474
Mike Schuchardt21638df2019-03-16 10:52:02 -07006475#ifdef VK_USE_PLATFORM_WIN32_KHR
6476bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6477 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006478 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006479 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006480 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006481 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006482 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006483 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006484 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006485 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006486 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006487 skip |=
6488 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006489 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006490 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6491 skip |= validate_struct_type(
6492 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6493 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6494 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6495 if (pSurfaceInfo != NULL) {
6496 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6497 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6498 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6499
6500 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6501 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6502 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6503 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006504 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6505 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006506
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006507 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6508 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6509 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6510 "VK_GOOGLE_surfaceless_query is not enabled.");
6511 }
6512
Mike Schuchardt21638df2019-03-16 10:52:02 -07006513 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6514 }
6515 return skip;
6516}
6517#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006518
6519bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6520 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006521 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006522 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6523 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006524 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006525 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6526 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6527 }
6528 return skip;
6529}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006530
6531bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006532 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006533 bool skip = false;
6534
6535 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006536 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006537 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006538 }
6539
6540 return skip;
6541}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006542
6543bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006544 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006545 bool skip = false;
6546
6547 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006548 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6549 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006550 }
6551
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006552 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006553 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006554 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6555 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006556 }
6557
6558 return skip;
6559}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006560
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006561bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6562 uint32_t bindingCount, const VkBuffer *pBuffers,
6563 const VkDeviceSize *pOffsets) const {
6564 bool skip = false;
6565 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006566 skip |=
6567 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6568 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6569 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006570 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6571 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006572 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6573 ") must be less than "
6574 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006575 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6576 }
6577
Jeff Bolz165818a2020-05-08 11:19:03 -05006578 for (uint32_t i = 0; i < bindingCount; ++i) {
6579 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006580 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006581 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006582 skip |=
6583 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6584 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006585 } else {
6586 if (pOffsets[i] != 0) {
6587 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006588 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6589 "] is not 0",
6590 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006591 }
6592 }
6593 }
6594 }
6595
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006596 return skip;
6597}
6598
Mark Lobodzinski84988402019-09-11 15:27:30 -06006599bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006600 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006601 bool skip = false;
6602 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006603 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6604 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006605 }
6606 return skip;
6607}
6608
6609bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006610 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006611 bool skip = false;
6612 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006613 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6614 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006615 }
6616 return skip;
6617}
Petr Kraus3d720392019-11-13 02:52:39 +01006618
6619bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6620 VkSemaphore semaphore, VkFence fence,
6621 uint32_t *pImageIndex) const {
6622 bool skip = false;
6623
6624 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006625 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6626 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006627 }
6628
6629 return skip;
6630}
6631
6632bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6633 uint32_t *pImageIndex) const {
6634 bool skip = false;
6635
6636 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006637 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6638 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006639 }
6640
6641 return skip;
6642}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006643
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006644bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6645 uint32_t firstBinding, uint32_t bindingCount,
6646 const VkBuffer *pBuffers,
6647 const VkDeviceSize *pOffsets,
6648 const VkDeviceSize *pSizes) const {
6649 bool skip = false;
6650
6651 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6652 for (uint32_t i = 0; i < bindingCount; ++i) {
6653 if (pOffsets[i] & 3) {
6654 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6655 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6656 }
6657 }
6658
6659 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6660 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6661 "%s: The firstBinding(%" PRIu32
6662 ") index is greater than or equal to "
6663 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6664 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6665 }
6666
6667 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6668 skip |=
6669 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6670 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6671 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6672 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6673 }
6674
6675 for (uint32_t i = 0; i < bindingCount; ++i) {
6676 // pSizes is optional and may be nullptr.
6677 if (pSizes != nullptr) {
6678 if (pSizes[i] != VK_WHOLE_SIZE &&
6679 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6680 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6681 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6682 ") is not VK_WHOLE_SIZE and is greater than "
6683 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6684 cmd_name, i, pSizes[i]);
6685 }
6686 }
6687 }
6688
6689 return skip;
6690}
6691
6692bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6693 uint32_t firstCounterBuffer,
6694 uint32_t counterBufferCount,
6695 const VkBuffer *pCounterBuffers,
6696 const VkDeviceSize *pCounterBufferOffsets) const {
6697 bool skip = false;
6698
6699 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6700 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6701 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6702 "%s: The firstCounterBuffer(%" PRIu32
6703 ") index is greater than or equal to "
6704 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6705 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6706 }
6707
6708 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6709 skip |=
6710 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6711 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6712 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6713 cmd_name, firstCounterBuffer, counterBufferCount,
6714 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6715 }
6716
6717 return skip;
6718}
6719
6720bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6721 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6722 const VkBuffer *pCounterBuffers,
6723 const VkDeviceSize *pCounterBufferOffsets) const {
6724 bool skip = false;
6725
6726 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6727 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6728 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6729 "%s: The firstCounterBuffer(%" PRIu32
6730 ") index is greater than or equal to "
6731 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6732 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6733 }
6734
6735 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6736 skip |=
6737 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6738 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6739 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6740 cmd_name, firstCounterBuffer, counterBufferCount,
6741 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6742 }
6743
6744 return skip;
6745}
6746
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006747bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6748 uint32_t firstInstance, VkBuffer counterBuffer,
6749 VkDeviceSize counterBufferOffset,
6750 uint32_t counterOffset, uint32_t vertexStride) const {
6751 bool skip = false;
6752
6753 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006754 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6755 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6756 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6757 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006758 }
6759
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006760 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006761 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006762 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006763 }
6764
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006765 return skip;
6766}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006767
6768bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6769 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6770 const VkAllocationCallbacks *pAllocator,
6771 VkSamplerYcbcrConversion *pYcbcrConversion,
6772 const char *apiName) const {
6773 bool skip = false;
6774
6775 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006776 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006777 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006778 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006779 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6780 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006781 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006782 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006783 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006784
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006785#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006786 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006787 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006788#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006789 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006790#endif
6791
sfricke-samsung1a72f942020-07-25 12:09:18 -07006792 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006793
6794 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006795 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006796 const VkComponentMapping components = pCreateInfo->components;
6797 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6798 if (FormatIsXChromaSubsampled(format) == true) {
6799 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6800 skip |=
6801 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006802 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6803 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006804 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006805 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006806
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006807 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6808 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6809 skip |= LogError(
6810 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6811 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6812 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6813 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6814 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006815
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006816 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6817 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6818 skip |=
6819 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006820 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6821 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006822 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006823 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006824
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006825 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6826 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6827 skip |=
6828 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006829 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6830 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006831 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006832 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006833
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006834 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006835 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6836 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6837 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006838 skip |=
6839 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006840 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6841 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006842 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6843 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006844 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006845 }
6846
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006847 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6848 // Checks same VU multiple ways in order to give a more useful error message
6849 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6850 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6851 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6852 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6853 skip |= LogError(
6854 device, vuid,
6855 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6856 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6857 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6858 string_VkComponentSwizzle(components.b));
6859 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006860
sfricke-samsunged028b02021-09-06 23:14:51 -07006861 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6862 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006863 // 3 = no [a]
6864 // 2 = no [b,a]
6865 // 1 = no [g,b,a]
6866 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006867 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006868
sfricke-samsunged028b02021-09-06 23:14:51 -07006869 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6870 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006871 skip |= LogError(device, vuid,
6872 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6873 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6874 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6875 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006876 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006877 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6878 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6879 skip |= LogError(device, vuid,
6880 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6881 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6882 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6883 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6884 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006885 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006886 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6887 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6888 skip |= LogError(device, vuid,
6889 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6890 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6891 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6892 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6893 string_VkComponentSwizzle(components.b));
6894 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006895 }
6896 }
6897
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006898 return skip;
6899}
6900
6901bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6902 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6903 const VkAllocationCallbacks *pAllocator,
6904 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6905 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6906 "vkCreateSamplerYcbcrConversion");
6907}
6908
6909bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6910 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6911 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6912 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6913 "vkCreateSamplerYcbcrConversionKHR");
6914}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006915
6916bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6917 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6918 bool skip = false;
6919 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6920 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6921
6922 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006923 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6924 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6925 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6926 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6927 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006928 }
6929 return skip;
6930}
sourav parmara96ab1a2020-04-25 16:28:23 -07006931
6932bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006933 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006934 bool skip = false;
6935 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6936 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6937 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6938 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006939 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006940 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6941 skip |= LogError(
6942 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6943 "vkCopyAccelerationStructureToMemoryKHR: The "
6944 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6945 }
6946 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6947 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6948 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6949 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6950 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6951 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006952 return skip;
6953}
6954
6955bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6956 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6957 bool skip = false;
6958 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6959 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6960 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6961 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6962 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006963 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6964 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006965 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006966 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006967 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006968 return skip;
6969}
6970
6971bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6972 const char *api_name) const {
6973 bool skip = false;
6974 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6975 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6976 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6977 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6978 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6979 api_name);
6980 }
6981 return skip;
6982}
6983
6984bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006985 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006986 bool skip = false;
6987 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006988 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006989 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006990 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006991 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6992 "vkCopyAccelerationStructureKHR: The "
6993 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006994 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006995 return skip;
6996}
6997
6998bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6999 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
7000 bool skip = false;
7001 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
7002 return skip;
7003}
7004
7005bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06007006 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007007 bool skip = false;
7008 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007009 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07007010 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
7011 }
7012 return skip;
7013}
7014
7015bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007016 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007017 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007018 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007019 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007020 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7021 skip |= LogError(
7022 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
7023 "vkCopyMemoryToAccelerationStructureKHR: The "
7024 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007025 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007026 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
7027 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07007028 return skip;
7029}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06007030
sourav parmara96ab1a2020-04-25 16:28:23 -07007031bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
7032 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
7033 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007034 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07007035 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
7036 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007037 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007038 pInfo->src.deviceAddress);
7039 }
sourav parmar83c31b12020-05-06 12:30:54 -07007040 return skip;
7041}
7042bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7043 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7044 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7045 bool skip = false;
7046 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7047 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007048 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7049 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7050 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7051 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7052 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7053 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7054 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7055 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7056 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7057 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7058 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7059 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7060 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7061 }
sourav parmar83c31b12020-05-06 12:30:54 -07007062 }
7063 return skip;
7064}
7065bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7066 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7067 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7068 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007069 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007070 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7071 skip |= LogError(
7072 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7073 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7074 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7075 }
sourav parmar83c31b12020-05-06 12:30:54 -07007076 if (dataSize < accelerationStructureCount * stride) {
7077 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7078 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007079 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007080 dataSize, accelerationStructureCount, stride);
7081 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007082
sourav parmar83c31b12020-05-06 12:30:54 -07007083 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7084 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007085 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7086 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7087 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7088 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7089 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7090 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7091 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7092 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7093 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7094 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7095 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7096 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7097 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7098 }
sourav parmar83c31b12020-05-06 12:30:54 -07007099 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007100
7101 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7102 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007103 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7104 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7105 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7106 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7107 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007108 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007109 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7110 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7111 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7112 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7113 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007114 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7115 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7116 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7117 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7118 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7119 stride);
7120 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7121 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7122 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7123 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7124 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7125 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007126 }
7127 }
sourav parmar83c31b12020-05-06 12:30:54 -07007128 return skip;
7129}
7130bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7131 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7132 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007133 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007134 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7135 skip |= LogError(
7136 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7137 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7138 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007139 }
7140 return skip;
7141}
7142
7143bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007144 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7145 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7146 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7147 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007148 uint32_t width, uint32_t height, uint32_t depth) const {
7149 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007150 // RayGen
7151 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7152 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7153 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007154 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007155 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7156 0) {
7157 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7158 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7159 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7160 }
7161 // Callable
7162 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7163 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7164 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7165 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007166 }
7167 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7168 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7169 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007170 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7171 }
7172 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7173 0) {
7174 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7175 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7176 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007177 }
7178 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007179 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7180 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7181 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7182 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007183 }
7184 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7185 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007186 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7187 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007188 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007189 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7190 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7191 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7192 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7193 }
sourav parmar83c31b12020-05-06 12:30:54 -07007194 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007195 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7196 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7197 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7198 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007199 }
7200 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7201 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7202 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007203 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7204 }
7205 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7206 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7207 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7208 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7209 }
7210 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007211 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007212 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7213 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7214 }
7215 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7216 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007217 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007218 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7219 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007220 }
7221
sourav parmarcd5fb182020-07-17 12:58:44 -07007222 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7223 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007224 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007225 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7226 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7227 }
7228
7229 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7230 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007231 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007232 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7233 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007234 }
7235 return skip;
7236}
7237
sourav parmarcd5fb182020-07-17 12:58:44 -07007238bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7239 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7240 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7241 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007242 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007243 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007244 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7245 skip |= LogError(
7246 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7247 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7248 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007249 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007250 // RayGen
7251 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7252 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7253 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007254 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007255 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7256 0) {
7257 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7258 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7259 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7260 }
7261 // Callabe
7262 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7263 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7264 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7265 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007266 }
7267 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7268 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007269 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7270 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7271 }
7272 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7273 0) {
7274 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7275 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7276 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007277 }
7278 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007279 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7280 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7281 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7282 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007283 }
7284 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7285 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007286 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7287 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007288 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007289 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7290 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7291 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7292 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7293 }
sourav parmar83c31b12020-05-06 12:30:54 -07007294 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007295 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7296 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7297 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7298 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007299 }
7300 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7301 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007302 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7303 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7304 }
7305 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7306 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7307 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7308 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007309 }
7310
sourav parmarcd5fb182020-07-17 12:58:44 -07007311 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7312 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7313 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007314 }
7315 return skip;
7316}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007317
7318bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7319 VkDeviceAddress indirectDeviceAddress) const {
7320 bool skip = false;
7321 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7322 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7323 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007324 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007325 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7326 "feature must be enabled.");
7327 }
7328
7329 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7330 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7331 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7332 }
7333 return skip;
7334}
7335
sourav parmar83c31b12020-05-06 12:30:54 -07007336bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7337 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7338 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7339 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7340 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7341 uint32_t width, uint32_t height, uint32_t depth) const {
7342 bool skip = false;
7343 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7344 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7345 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7346 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7347 }
7348 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7349 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7350 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7351 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7352 }
7353 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7354 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7355 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7356 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7357 }
7358
7359 // hitShader
7360 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7361 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7362 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7363 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7364 }
7365 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7366 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7367 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7368 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7369 }
7370 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7371 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7372 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7373 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7374 }
7375
7376 // missShader
7377 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7378 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7379 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7380 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7381 }
7382 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7383 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7384 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7385 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7386 }
7387 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7388 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7389 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7390 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7391 }
7392
7393 // raygenShader
7394 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7395 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7396 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007397 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7398 }
7399 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7400 skip |=
7401 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7402 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7403 }
7404 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7405 skip |=
7406 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7407 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7408 }
7409 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7410 skip |=
7411 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7412 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007413 }
7414 return skip;
7415}
7416
sourav parmar83c31b12020-05-06 12:30:54 -07007417bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007418 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7419 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007420 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007421 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7422 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007423 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7424 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007425 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007426 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7427 }
7428 return skip;
7429}
7430
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007431bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7432 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007433 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007434 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007435
7436 if (!physical_device_features.multiViewport) {
7437 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007438 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7439 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007440 viewportCount);
7441 }
7442 } else { // multiViewport enabled
7443 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007444 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7445 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007446 ") must "
7447 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007448 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007449 }
7450 }
7451
7452 if (pViewports) {
7453 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7454 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007455 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007456 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007457 }
7458 }
7459
7460 return skip;
7461}
7462
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007463bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7464 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007465 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007466 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7467 return skip;
7468}
7469
7470bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7471 const VkViewport *pViewports) const {
7472 bool skip = false;
7473 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7474 return skip;
7475}
7476
7477bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7478 const VkRect2D *pScissors, bool is_ext) const {
7479 bool skip = false;
7480 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007481
7482 if (!physical_device_features.multiViewport) {
7483 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007484 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7485 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007486 ") must "
7487 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007488 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007489 }
7490 } else { // multiViewport enabled
7491 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007492 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7493 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007494 ") must "
7495 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007496 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007497 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007498 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7499 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007500 ") must "
7501 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007502 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007503 }
7504 }
7505
7506 if (pScissors) {
7507 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7508 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7509
7510 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007511 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7512 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007513 }
7514
7515 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007516 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7517 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007518 }
7519
7520 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7521 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007522 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7523 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7524 "] will overflow int32_t.",
7525 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007526 }
7527
7528 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7529 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007530 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7531 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7532 "] will overflow int32_t.",
7533 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7534 }
7535 }
7536 }
7537
7538 return skip;
7539}
7540
7541bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7542 const VkRect2D *pScissors) const {
7543 bool skip = false;
7544 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7545 return skip;
7546}
7547
7548bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7549 const VkRect2D *pScissors) const {
7550 bool skip = false;
7551 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7552 return skip;
7553}
7554
7555bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7556 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7557 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7558 bool is_2ext) const {
7559 bool skip = false;
7560 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7561 if (firstBinding >= device_limits.maxVertexInputBindings) {
7562 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7563 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7564 firstBinding, device_limits.maxVertexInputBindings);
7565 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7566 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7567 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7568 ") must be less than "
7569 "maxVertexInputBindings (%" PRIu32 ")",
7570 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7571 }
7572
7573 for (uint32_t i = 0; i < bindingCount; ++i) {
7574 if (pBuffers[i] == VK_NULL_HANDLE) {
7575 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7576 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7577 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7578 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7579 } else {
7580 if (pOffsets[i] != 0) {
7581 skip |=
7582 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7583 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7584 }
7585 }
7586 }
7587 if (pStrides) {
7588 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7589 skip |=
7590 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7591 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7592 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007593 }
7594 }
7595 }
7596
7597 return skip;
7598}
7599
7600bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7601 uint32_t bindingCount, const VkBuffer *pBuffers,
7602 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7603 const VkDeviceSize *pStrides) const {
7604 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007605 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7606 return skip;
7607}
Piers Daniell39842ee2020-07-10 16:42:33 -06007608
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007609bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7610 uint32_t bindingCount, const VkBuffer *pBuffers,
7611 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7612 const VkDeviceSize *pStrides) const {
7613 bool skip = false;
7614 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007615 return skip;
7616}
sourav parmarcd5fb182020-07-17 12:58:44 -07007617
7618bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7619 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7620 bool skip = false;
7621 for (uint32_t i = 0; i < infoCount; ++i) {
7622 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7623 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7624 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7625 }
7626 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7627 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7628 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7629 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7630 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7631 api_name);
7632 }
7633 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7634 skip |=
7635 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7636 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7637 }
7638 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7639 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7640 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7641 }
7642 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7643 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7644 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7645 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7646 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7647 api_name);
7648 }
7649 if (pInfos[i].pGeometries) {
7650 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7651 skip |= validate_ranged_enum(
7652 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7653 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7654 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7655 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007656 skip |= validate_struct_type(
7657 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7658 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7659 &(pInfos[i].pGeometries[j].geometry.triangles),
7660 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7661 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7662 skip |= validate_struct_pnext(
7663 api_name,
7664 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7665 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7666 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7667 skip |=
7668 validate_ranged_enum(api_name,
7669 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7670 ParameterName::IndexVector{i, j}),
7671 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7672 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7673 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7674 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7675 &pInfos[i].pGeometries[j].geometry.triangles,
7676 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7677 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7678 skip |= validate_ranged_enum(
7679 api_name,
7680 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7681 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7682 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7683
7684 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7685 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7686 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7687 }
7688 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7689 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7690 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7691 skip |=
7692 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7693 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7694 api_name);
7695 }
7696 }
7697 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7698 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7699 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7700 &pInfos[i].pGeometries[j].geometry.instances,
7701 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7702 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7703 skip |= validate_struct_type(
7704 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7705 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7706 &(pInfos[i].pGeometries[j].geometry.instances),
7707 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7708 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7709 skip |= validate_struct_pnext(
7710 api_name,
7711 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7712 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7713 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7714
7715 skip |= validate_bool32(api_name,
7716 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7717 ParameterName::IndexVector{i, j}),
7718 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7719 }
7720 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7721 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7722 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7723 &pInfos[i].pGeometries[j].geometry.aabbs,
7724 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7725 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7726 skip |= validate_struct_type(
7727 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7728 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7729 &(pInfos[i].pGeometries[j].geometry.aabbs),
7730 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7731 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7732 skip |= validate_struct_pnext(
7733 api_name,
7734 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7735 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7736 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7737 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7738 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7739 "(%s):stride must be less than or equal to 2^32-1", api_name);
7740 }
7741 }
7742 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7743 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7744 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7745 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7746 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7747 api_name);
7748 }
7749 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7750 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7751 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7752 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7753 "of elements of"
7754 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7755 api_name);
7756 }
7757 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7758 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7759 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7760 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7761 api_name);
7762 }
7763 }
7764 }
7765 }
7766 if (pInfos[i].ppGeometries != NULL) {
7767 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7768 skip |= validate_ranged_enum(
7769 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7770 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7771 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7772 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007773 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7774 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7775 &pInfos[i].ppGeometries[j]->geometry.triangles,
7776 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7777 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7778 skip |= validate_struct_type(
7779 api_name,
7780 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7781 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7782 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7783 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7784 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7785 skip |= validate_struct_pnext(
7786 api_name,
7787 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7788 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7789 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7790 skip |= validate_ranged_enum(api_name,
7791 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7792 ParameterName::IndexVector{i, j}),
7793 "VkFormat", AllVkFormatEnums,
7794 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7795 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7796 skip |= validate_ranged_enum(api_name,
7797 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7798 ParameterName::IndexVector{i, j}),
7799 "VkIndexType", AllVkIndexTypeEnums,
7800 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7801 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7802 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7803 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7804 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7805 }
7806 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7807 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7808 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7809 skip |=
7810 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7811 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7812 api_name);
7813 }
7814 }
7815 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7816 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7817 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7818 &pInfos[i].ppGeometries[j]->geometry.instances,
7819 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7820 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7821 skip |= validate_struct_type(
7822 api_name,
7823 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7824 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7825 &(pInfos[i].ppGeometries[j]->geometry.instances),
7826 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7827 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7828 skip |= validate_struct_pnext(
7829 api_name,
7830 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7831 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7832 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7833 skip |= validate_bool32(api_name,
7834 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7835 ParameterName::IndexVector{i, j}),
7836 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7837 }
7838 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7839 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7840 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7841 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7842 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7843 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7844 skip |= validate_struct_type(
7845 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7846 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7847 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7848 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7849 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7850 skip |= validate_struct_pnext(
7851 api_name,
7852 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7853 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7854 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7855 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7856 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7857 "(%s):stride must be less than or equal to 2^32-1", api_name);
7858 }
7859 }
7860 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7861 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7862 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7863 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7864 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7865 api_name);
7866 }
7867 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7868 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7869 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7870 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7871 "of elements of"
7872 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7873 api_name);
7874 }
7875 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7876 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7877 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7878 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7879 api_name);
7880 }
7881 }
7882 }
7883 }
7884 }
7885 return skip;
7886}
7887bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7888 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7889 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7890 bool skip = false;
7891 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7892 for (uint32_t i = 0; i < infoCount; ++i) {
7893 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7894 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7895 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7896 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7897 "scratchData.deviceAddress member must be a multiple of "
7898 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7899 }
7900 for (uint32_t k = 0; k < infoCount; ++k) {
7901 if (i == k) continue;
7902 bool found = false;
7903 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007904 skip |=
7905 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7906 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7907 ") of pInfos must "
7908 "not be "
7909 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7910 ") of pInfos.",
7911 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007912 found = true;
7913 }
7914 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007915 skip |=
7916 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7917 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7918 ") of pInfos must "
7919 "not be "
7920 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7921 ") of pInfos.",
7922 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007923 found = true;
7924 }
7925 if (found) break;
7926 }
7927 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7928 if (pInfos[i].pGeometries) {
7929 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7930 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7931 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7932 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7933 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7934 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7935 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7936 }
7937 } else {
7938 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7939 skip |=
7940 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7941 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7942 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7943 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7944 }
7945 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007946 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007947 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7948 skip |= LogError(
7949 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7950 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7951 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7952 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007953 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7954 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007955 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7956 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7957 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7958 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7959 }
7960 }
7961 } else if (pInfos[i].ppGeometries) {
7962 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7963 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7964 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7965 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7966 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7967 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7968 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7969 }
7970 } else {
7971 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7972 skip |=
7973 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7974 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7975 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7976 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7977 }
7978 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007979 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007980 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7981 skip |= LogError(
7982 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7983 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7984 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7985 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007986 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7987 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007988 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7989 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7990 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7991 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7992 }
7993 }
7994 }
7995 }
7996 }
7997 return skip;
7998}
7999
8000bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
8001 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8002 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
8003 const uint32_t *const *ppMaxPrimitiveCounts) const {
8004 bool skip = false;
8005 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
8006 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008007 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008008 if (!ray_tracing_acceleration_structure_features ||
8009 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
8010 skip |= LogError(
8011 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
8012 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
8013 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
8014 }
8015 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008016 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8017 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8018 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
8019 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
8020 "scratchData.deviceAddress member must be a multiple of "
8021 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8022 }
8023 for (uint32_t k = 0; k < infoCount; ++k) {
8024 if (i == k) continue;
8025 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008026 skip |= LogError(
8027 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
8028 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
8029 ") "
8030 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
8031 "any other element [%" PRIu32 ") of pInfos.",
8032 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008033 break;
8034 }
8035 }
8036 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8037 if (pInfos[i].pGeometries) {
8038 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8039 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8040 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8041 skip |= LogError(
8042 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8043 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8044 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8045 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8046 }
8047 } else {
8048 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8049 skip |= LogError(
8050 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8051 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8052 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8053 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8054 }
8055 }
8056 }
8057 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8058 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8059 skip |= LogError(
8060 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8061 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8062 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8063 }
8064 }
8065 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8066 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8067 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8068 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8069 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8070 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8071 }
8072 }
8073 } else if (pInfos[i].ppGeometries) {
8074 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8075 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8076 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8077 skip |= LogError(
8078 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8079 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8080 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8081 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8082 }
8083 } else {
8084 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8085 skip |= LogError(
8086 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8087 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8088 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8089 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8090 }
8091 }
8092 }
8093 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8094 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8095 skip |= LogError(
8096 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8097 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8098 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8099 }
8100 }
8101 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8102 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8103 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8104 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8105 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8106 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8107 }
8108 }
8109 }
8110 }
8111 }
8112 return skip;
8113}
8114
8115bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8116 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8117 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8118 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8119 bool skip = false;
8120 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8121 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008122 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008123 if (!ray_tracing_acceleration_structure_features ||
8124 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8125 skip |=
8126 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8127 "vkBuildAccelerationStructuresKHR: The "
8128 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8129 }
8130 for (uint32_t i = 0; i < infoCount; ++i) {
8131 for (uint32_t j = 0; j < infoCount; ++j) {
8132 if (i == j) continue;
8133 bool found = false;
8134 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008135 skip |=
8136 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8137 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8138 ") of pInfos must "
8139 "not be "
8140 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8141 ") of pInfos.",
8142 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008143 found = true;
8144 }
8145 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008146 skip |=
8147 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8148 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8149 ") of pInfos must "
8150 "not be "
8151 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8152 ") of pInfos.",
8153 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008154 found = true;
8155 }
8156 if (found) break;
8157 }
8158 }
8159 return skip;
8160}
8161
8162bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8163 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8164 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8165 bool skip = false;
8166 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8167 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008168 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8169 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008170 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8171 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008172 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008173 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8174 }
8175 if (pBuildInfo != nullptr) {
8176 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8177 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8178 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8179 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8180 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008181 }
8182 return skip;
8183}
sfricke-samsungecafb192021-01-17 08:21:14 -08008184
Piers Daniellcb6d8032021-04-19 18:51:26 -06008185bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8186 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8187 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8188 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8189 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008190 const auto *vertex_attribute_divisor_features =
8191 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8192
Piers Daniellcb6d8032021-04-19 18:51:26 -06008193 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8194 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8195 skip |=
8196 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8197 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8198 }
8199
8200 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8201 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8202 skip |= LogError(
8203 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8204 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8205 }
8206
8207 // VUID-vkCmdSetVertexInputEXT-binding-04793
8208 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8209 bool binding_found = false;
8210 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8211 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8212 binding_found = true;
8213 break;
8214 }
8215 }
8216 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008217 skip |= LogError(
8218 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8219 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008220 }
8221 }
8222
8223 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8224 if (vertexBindingDescriptionCount > 1) {
8225 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8226 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8227 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8228 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8229 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008230 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8231 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008232 }
8233 }
8234 }
8235 }
8236
8237 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8238 if (vertexAttributeDescriptionCount > 1) {
8239 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8240 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8241 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8242 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8243 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008244 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8245 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008246 }
8247 }
8248 }
8249 }
8250
8251 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8252 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8253 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008254 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8255 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8256 "].binding is greater than maxVertexInputBindings",
8257 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008258 }
8259
8260 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8261 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008262 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8263 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8264 "].stride is greater than maxVertexInputBindingStride",
8265 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008266 }
8267
8268 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8269 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8270 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8271 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008272 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8273 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008274 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8275 binding);
8276 }
8277
8278 if (pVertexBindingDescriptions[binding].divisor > 1) {
8279 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8280 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8281 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008282 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8283 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008284 "vertexAttributeInstanceRateDivisor is not enabled",
8285 binding);
8286 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008287 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008288 if (pVertexBindingDescriptions[binding].divisor >
8289 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008290 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8291 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8292 "].divisor is greater than maxVertexAttribDivisor",
8293 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008294 }
8295
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008296 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008297 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008298 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8299 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8300 "].divisor is greater than 1 but inputRate "
8301 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8302 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008303 }
8304 }
8305 }
8306 }
8307
8308 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008309 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008310 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008311 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8312 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8313 "].location is greater than maxVertexInputAttributes",
8314 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008315 }
8316
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008317 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008318 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008319 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8320 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8321 "].binding is greater than maxVertexInputBindings",
8322 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008323 }
8324
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008325 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008326 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008327 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8328 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8329 "].offset is greater than maxVertexInputAttributeOffset",
8330 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008331 }
8332
8333 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8334 VkFormatProperties properties;
8335 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8336 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8337 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008338 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8339 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008340 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8341 attribute);
8342 }
8343 }
8344
8345 return skip;
8346}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008347
8348bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8349 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8350 const void *pValues) const {
8351 bool skip = false;
8352 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8353 // Check that offset + size don't exceed the max.
8354 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8355 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008356 skip |=
8357 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8358 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8359 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008360 }
8361 if (size > max_push_constants_size - offset) {
8362 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008363 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8364 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008365 offset, size, max_push_constants_size);
8366 }
8367
8368 // size needs to be non-zero and a multiple of 4.
8369 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008370 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8371 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008372 }
8373
8374 // offset needs to be a multiple of 4.
8375 if ((offset & 0x3) != 0) {
8376 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008377 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008378 }
8379 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008380}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008381
8382bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8383 uint32_t srcCacheCount,
8384 const VkPipelineCache *pSrcCaches) const {
8385 bool skip = false;
8386 if (pSrcCaches) {
8387 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8388 if (pSrcCaches[index0] == dstCache) {
8389 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8390 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8391 report_data->FormatHandle(dstCache).c_str());
8392 break;
8393 }
8394 }
8395 }
8396 return skip;
8397}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008398
8399bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8400 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8401 uint32_t rangeCount,
8402 const VkImageSubresourceRange *pRanges) const {
8403 bool skip = false;
8404 if (!pColor) {
8405 skip |=
8406 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8407 }
8408 return skip;
8409}
8410
8411bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8412 const VkRenderPassBeginInfo *const rp_begin) const {
8413 bool skip = false;
8414 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8415 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8416 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008417 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008418 func_name, rp_begin->clearValueCount);
8419 }
8420 return skip;
8421}
8422
8423bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8424 VkSubpassContents) const {
8425 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8426 return skip;
8427}
8428
8429bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8430 const VkRenderPassBeginInfo *pRenderPassBegin,
8431 const VkSubpassBeginInfo *) const {
8432 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8433 return skip;
8434}
8435
8436bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8437 const VkSubpassBeginInfo *) const {
8438 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8439 return skip;
8440}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008441
8442bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8443 uint32_t firstDiscardRectangle,
8444 uint32_t discardRectangleCount,
8445 const VkRect2D *pDiscardRectangles) const {
8446 bool skip = false;
8447
8448 if (pDiscardRectangles) {
8449 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8450 const int64_t x_sum =
8451 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8452 if (x_sum > std::numeric_limits<int32_t>::max()) {
8453 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8454 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8455 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8456 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8457 }
8458
8459 const int64_t y_sum =
8460 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8461 if (y_sum > std::numeric_limits<int32_t>::max()) {
8462 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8463 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8464 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8465 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8466 }
8467 }
8468 }
8469
8470 return skip;
8471}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008472
8473bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8474 uint32_t queryCount, size_t dataSize, void *pData,
8475 VkDeviceSize stride, VkQueryResultFlags flags) const {
8476 bool skip = false;
8477
8478 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8479 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8480 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8481 }
8482
8483 return skip;
8484}
ziga-lunargcf340c42021-08-19 00:13:38 +02008485
8486bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8487 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8488 bool skip = false;
8489
8490 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8491 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8492 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8493 ") is not a multiple of 4.",
8494 pConditionalRenderingBegin->offset);
8495 }
8496
8497 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008498}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008499
8500bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8501 VkSurfaceKHR surface,
8502 uint32_t *pSurfaceFormatCount,
8503 VkSurfaceFormatKHR *pSurfaceFormats) const {
8504 bool skip = false;
8505 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8506 skip |= LogError(
8507 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8508 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8509 }
8510 return skip;
8511}
8512
8513bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8514 VkSurfaceKHR surface,
8515 uint32_t *pPresentModeCount,
8516 VkPresentModeKHR *pPresentModes) const {
8517 bool skip = false;
8518 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8519 skip |= LogError(
8520 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8521 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8522 }
8523 return skip;
8524}
8525
8526bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8527 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8528 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8529 bool skip = false;
8530 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8531 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8532 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8533 "VK_GOOGLE_surfaceless_query is not enabled.");
8534 }
8535 return skip;
8536}
8537
8538bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8539 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8540 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8541 bool skip = false;
8542 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8543 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8544 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8545 "VK_GOOGLE_surfaceless_query is not enabled.");
8546 }
8547 return skip;
8548}
8549
8550#ifdef VK_USE_PLATFORM_WIN32_KHR
8551bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8552 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8553 VkPresentModeKHR *pPresentModes) const {
8554 bool skip = false;
8555 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8556 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8557 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8558 "VK_GOOGLE_surfaceless_query is not enabled.");
8559 }
8560 return skip;
8561}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008562
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008563#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008564
8565bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8566 const char *func_name) const {
8567 bool skip = false;
8568
8569 if (pInfo && pInfo->pCreateInfo) {
8570 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8571 if (image_swapchain_create_info) {
8572 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8573 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8574 }
8575 }
8576
8577 return skip;
8578}
8579
8580bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8581 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8582 bool skip = false;
8583
8584 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8585
8586 return skip;
8587}
8588
8589bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8590 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8591 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8592 bool skip = false;
8593
8594 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8595
8596 return skip;
8597}