blob: 32c9e8af6a798b4a6eea19c742f9b61e946ead69 [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 }
1864 }
1865 }
1866
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001867 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1868 if (create_info.stageCount == 0) {
1869 skip |=
1870 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1871 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1872 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1873 }
1874 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1875 // ParameterName::IndexFormatSpecifier
1876 skip |= validate_struct_type_array(
1877 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1878 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
1879 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages,
1880 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1881 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06001882 "VUID-VkGraphicsPipelineCreateInfo-pStages-06600");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001883 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1884 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1885 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
1886 pCreateInfos[i].pRasterizationState,
1887 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1888 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1889 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001890 }
1891
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001892 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1893 if (create_info.pDynamicState != nullptr) {
1894 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001895 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1896 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001897 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1898 if (has_dynamic_viewport == true) {
1899 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1900 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001901 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001902 i);
1903 }
1904 has_dynamic_viewport = true;
1905 }
1906 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1907 if (has_dynamic_scissor == true) {
1908 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1909 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001910 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001911 i);
1912 }
1913 has_dynamic_scissor = true;
1914 }
1915 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1916 if (has_dynamic_line_width == true) {
1917 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1918 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001919 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001920 i);
1921 }
1922 has_dynamic_line_width = true;
1923 }
1924 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1925 if (has_dynamic_depth_bias == true) {
1926 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1927 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001928 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001929 i);
1930 }
1931 has_dynamic_depth_bias = true;
1932 }
1933 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1934 if (has_dynamic_blend_constant == true) {
1935 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1936 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001937 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001938 i);
1939 }
1940 has_dynamic_blend_constant = true;
1941 }
1942 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1943 if (has_dynamic_depth_bounds == true) {
1944 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1945 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001946 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001947 i);
1948 }
1949 has_dynamic_depth_bounds = true;
1950 }
1951 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1952 if (has_dynamic_stencil_compare == true) {
1953 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1954 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001955 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001956 i);
1957 }
1958 has_dynamic_stencil_compare = true;
1959 }
1960 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1961 if (has_dynamic_stencil_write == true) {
1962 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1963 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001964 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001965 i);
1966 }
1967 has_dynamic_stencil_write = true;
1968 }
1969 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1970 if (has_dynamic_stencil_reference == true) {
1971 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1972 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001973 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001974 i);
1975 }
1976 has_dynamic_stencil_reference = true;
1977 }
1978 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1979 if (has_dynamic_viewport_w_scaling_nv == true) {
1980 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1981 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001982 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001983 i);
1984 }
1985 has_dynamic_viewport_w_scaling_nv = true;
1986 }
1987 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1988 if (has_dynamic_discard_rectangle_ext == true) {
1989 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1990 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001991 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001992 i);
1993 }
1994 has_dynamic_discard_rectangle_ext = true;
1995 }
1996 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1997 if (has_dynamic_sample_locations_ext == true) {
1998 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1999 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002000 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002001 i);
2002 }
2003 has_dynamic_sample_locations_ext = true;
2004 }
2005 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
2006 if (has_dynamic_exclusive_scissor_nv == true) {
2007 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2008 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002009 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002010 i);
2011 }
2012 has_dynamic_exclusive_scissor_nv = true;
2013 }
2014 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
2015 if (has_dynamic_shading_rate_palette_nv == true) {
2016 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2017 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002018 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002019 i);
2020 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06002021 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07002022 }
2023 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
2024 if (has_dynamic_viewport_course_sample_order_nv == true) {
2025 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2026 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002027 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002028 i);
2029 }
2030 has_dynamic_viewport_course_sample_order_nv = true;
2031 }
2032 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
2033 if (has_dynamic_line_stipple == true) {
2034 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2035 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002036 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002037 i);
2038 }
2039 has_dynamic_line_stipple = true;
2040 }
Piers Daniell39842ee2020-07-10 16:42:33 -06002041 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
2042 if (has_dynamic_cull_mode) {
2043 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2044 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002045 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002046 i);
2047 }
2048 has_dynamic_cull_mode = true;
2049 }
2050 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
2051 if (has_dynamic_front_face) {
2052 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2053 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002054 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002055 i);
2056 }
2057 has_dynamic_front_face = true;
2058 }
2059 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
2060 if (has_dynamic_primitive_topology) {
2061 skip |= LogError(
2062 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2063 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002064 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002065 i);
2066 }
2067 has_dynamic_primitive_topology = true;
2068 }
2069 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2070 if (has_dynamic_viewport_with_count) {
2071 skip |= LogError(
2072 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2073 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002074 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002075 i);
2076 }
2077 has_dynamic_viewport_with_count = true;
2078 }
2079 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2080 if (has_dynamic_scissor_with_count) {
2081 skip |= LogError(
2082 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2083 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002084 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002085 i);
2086 }
2087 has_dynamic_scissor_with_count = true;
2088 }
2089 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2090 if (has_dynamic_vertex_input_binding_stride) {
2091 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2092 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2093 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002094 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002095 i);
2096 }
2097 has_dynamic_vertex_input_binding_stride = true;
2098 }
2099 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2100 if (has_dynamic_depth_test_enable) {
2101 skip |= LogError(
2102 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2103 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002104 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002105 i);
2106 }
2107 has_dynamic_depth_test_enable = true;
2108 }
2109 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2110 if (has_dynamic_depth_write_enable) {
2111 skip |= LogError(
2112 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2113 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002114 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002115 i);
2116 }
2117 has_dynamic_depth_write_enable = true;
2118 }
2119 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2120 if (has_dynamic_depth_compare_op) {
2121 skip |=
2122 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2123 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002124 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002125 i);
2126 }
2127 has_dynamic_depth_compare_op = true;
2128 }
2129 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2130 if (has_dynamic_depth_bounds_test_enable) {
2131 skip |= LogError(
2132 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2133 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002134 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002135 i);
2136 }
2137 has_dynamic_depth_bounds_test_enable = true;
2138 }
2139 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2140 if (has_dynamic_stencil_test_enable) {
2141 skip |= LogError(
2142 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2143 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002144 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002145 i);
2146 }
2147 has_dynamic_stencil_test_enable = true;
2148 }
2149 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2150 if (has_dynamic_stencil_op) {
2151 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2152 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002153 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002154 i);
2155 }
2156 has_dynamic_stencil_op = true;
2157 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002158 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2159 // Not allowed for graphics pipelines
2160 skip |= LogError(
2161 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2162 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002163 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2164 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002165 i, state_index);
2166 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002167 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2168 if (has_patch_control_points) {
2169 skip |= LogError(
2170 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2171 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002172 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002173 i);
2174 }
2175 has_patch_control_points = true;
2176 }
2177 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2178 if (has_rasterizer_discard_enable) {
2179 skip |= LogError(
2180 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2181 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002182 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002183 i);
2184 }
2185 has_rasterizer_discard_enable = true;
2186 }
2187 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2188 if (has_depth_bias_enable) {
2189 skip |= LogError(
2190 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2191 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002192 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002193 i);
2194 }
2195 has_depth_bias_enable = true;
2196 }
2197 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2198 if (has_logic_op) {
2199 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2200 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002201 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002202 i);
2203 }
2204 has_logic_op = true;
2205 }
2206 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2207 if (has_primitive_restart_enable) {
2208 skip |= LogError(
2209 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2210 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002211 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002212 i);
2213 }
2214 has_primitive_restart_enable = true;
2215 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002216 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2217 if (has_dynamic_vertex_input) {
2218 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002219 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2220 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2221 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002222 }
2223 has_dynamic_vertex_input = true;
2224 }
Petr Kraus299ba622017-11-24 03:09:03 +01002225 }
2226 }
2227
sfricke-samsung3b944422021-01-23 02:15:19 -08002228 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2229 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2230 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002231 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2232 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002233 i);
2234 }
2235
2236 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2237 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2238 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002239 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002240 i);
2241 }
2242
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002243 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2244 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002245 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002246 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2247 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2248 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002249 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002250 }
2251
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002252 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002253
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002254 // Collect active stages and other information
2255 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002256 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002257 bool has_eval = false;
2258 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002259 if (create_info.pStages != nullptr) {
2260 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2261 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002262
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002263 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002264 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002265 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002266 has_eval = true;
2267 }
2268
Tony-LunarGd29cc032022-05-13 14:38:27 -06002269 skip |= validate_required_pointer(
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002270 "vkCreateGraphicsPipelines",
Tony-LunarGd29cc032022-05-13 14:38:27 -06002271 ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}),
2272 create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter");
2273
2274 if (create_info.pStages[stage_index].pName) {
2275 skip |= validate_string(
2276 "vkCreateGraphicsPipelines",
2277 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2278 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
2279 }
ziga-lunargc6341372021-07-28 12:57:42 +02002280
2281 std::stringstream msg;
2282 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2283 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002284 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002285 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002286 }
2287
2288 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002289 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2290 skip |=
2291 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2292 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2293 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2294 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002295
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002296 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002297 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2298
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002299 skip |= validate_struct_pnext(
2300 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002301 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002302 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2303 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2304 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2305 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002306
2307 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002308 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002309 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2310 }
2311
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002312 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002313 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2314 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002315 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002316 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2317 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2318
2319 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002320 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002321 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002322
2323 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002324 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002325 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2326
2327 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2328 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002329 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002330 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2331
2332 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002333 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002334 }
2335
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002336 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2337 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002338
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002339 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002340 skip |=
2341 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2342 "vkCreateGraphicsPipelines: pararameter "
2343 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2344 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002345 }
2346
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002347 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002348 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002349 skip |=
2350 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2351 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2352 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2353 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2354 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002355 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2356 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002357 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002358 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2359 skip |=
2360 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2361 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002362 create_info.pVertexInputState->vertexBindingDescriptionCount,
2363 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002364 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2365
2366 skip |= validate_array(
2367 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2368 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2369 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2370 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2371
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002372 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002373 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002374 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002375 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002376 skip |= validate_ranged_enum(
2377 "vkCreateGraphicsPipelines",
2378 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2379 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002380 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002381 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2382 }
2383 }
2384
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002385 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002386 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002387 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002388 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002389 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002390 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002391 skip |= validate_ranged_enum(
2392 "vkCreateGraphicsPipelines",
2393 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2394 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002395 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002396 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002397 if (FormatIsDepthOrStencil(format)) {
2398 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2399 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2400 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2401 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002402 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2403 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002404 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2405 "alignment, replace with a color format.",
2406 i, vertex_attribute_description_index, string_VkFormat(format));
2407 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002408 }
2409 }
2410
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002411 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2413 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002414 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2415 ") is "
2416 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002417 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002418 }
2419
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002420 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 skip |=
2422 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2423 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002424 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2425 ") is "
2426 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002427 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002428 }
2429
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002430 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002431 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2432 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002433 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2434 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002435 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2436 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002437 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2438 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 "(%" PRIu32 ") is not distinct.",
2440 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002441 }
2442 vertex_bindings.insert(vertex_bind_desc.binding);
2443
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002444 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002445 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2446 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002447 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2448 "].binding (%" PRIu32
2449 ") is "
2450 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002451 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002452 }
2453
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002454 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002455 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2456 "vkCreateGraphicsPipelines: parameter "
2457 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2458 "].stride (%" PRIu32
2459 ") is greater "
2460 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2461 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002462 }
2463 }
2464
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002465 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002466 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2467 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002468 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2469 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002470 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2471 "vkCreateGraphicsPipelines: parameter "
2472 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2473 "].location (%" PRIu32 ") is not distinct.",
2474 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002475 }
2476 attribute_locations.insert(vertex_attrib_desc.location);
2477
2478 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2479 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002480 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2481 "vkCreateGraphicsPipelines: parameter "
2482 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2483 "].binding (%" PRIu32
2484 ") does not exist "
2485 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2486 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002487 }
2488
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002489 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002490 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2491 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002492 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2493 "].location (%" PRIu32
2494 ") is "
2495 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002496 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497 }
2498
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002499 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002500 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2501 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002502 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2503 "].binding (%" PRIu32
2504 ") is "
2505 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002506 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002507 }
2508
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002509 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002510 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2511 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002512 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2513 "].offset (%" PRIu32
2514 ") is "
2515 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002516 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002517 }
2518 }
2519 }
2520
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002521 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2522 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002523 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002524 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002525 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2526 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002527 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002528 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002529 i, i);
2530 } else {
2531 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2532 skip |= validate_struct_pnext(
2533 "vkCreateGraphicsPipelines",
2534 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002535 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002536 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2537 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002539 skip |= validate_reserved_flags(
2540 "vkCreateGraphicsPipelines",
2541 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002542 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002543
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002544 if (create_info.pTessellationState->patchControlPoints == 0 ||
2545 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2546 skip |=
2547 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2548 "vkCreateGraphicsPipelines: invalid parameter "
2549 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2550 ". patchControlPoints "
2551 "should be >0 and <=%" PRIu32 ".",
2552 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002553 }
2554 }
2555 }
2556
2557 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002558 if ((create_info.pRasterizationState != nullptr) &&
2559 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2560 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002561 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2562 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2563 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2564 "].pViewportState (=NULL) is not a valid pointer.",
2565 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002567 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002568
2569 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2571 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2572 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2573 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002574 }
2575
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002576 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002577 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002578 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2579 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002580 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2581 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002582 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002583 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002584 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002585 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002586 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002587 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002588 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002589 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002590 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002591 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002592 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002593 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594
2595 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002596 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002597 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002598 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002600 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002601 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002602 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002603 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002604 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002605 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2606 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002607 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002608 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2609 const auto depth_clip_control_struct =
2610 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002611
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002612 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002613 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002614 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2615 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2616 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2617 ") is not 1.",
2618 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002619 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002620
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002621 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002622 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2623 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2624 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2625 ") is not 1.",
2626 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002627 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002628
Dave Houlton142c4cb2018-10-17 15:04:41 -06002629 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2630 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002631 skip |= LogError(
2632 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2633 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2634 "disabled, but pCreateInfos[%" PRIu32
2635 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2636 ") is not 1.",
2637 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002638 }
2639
Jeff Bolz9af91c52018-09-01 21:53:57 -05002640 if (shading_rate_image_struct &&
2641 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002642 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2643 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2644 "disabled, but pCreateInfos[%" PRIu32
2645 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2646 ") is neither 0 nor 1.",
2647 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002648 }
2649
Petr Krausa6103552017-11-16 21:21:58 +01002650 } else { // multiViewport enabled
2651 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002652 if (!has_dynamic_viewport_with_count) {
2653 skip |= LogError(
2654 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2655 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2656 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002657 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002658 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2659 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2660 "].pViewportState->viewportCount (=%" PRIu32
2661 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2662 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002663 } else if (has_dynamic_viewport_with_count) {
2664 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2665 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2666 "].pViewportState->viewportCount (=%" PRIu32
2667 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2668 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669 }
Petr Krausa6103552017-11-16 21:21:58 +01002670
2671 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002672 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002673 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2674 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2675 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002676 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002677 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002678 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2679 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002680 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002681 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2682 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2683 "].pViewportState->scissorCount (=%" PRIu32
2684 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2685 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002686 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002687 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2688 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2689 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2690 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002691 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2692 "].pViewportState->scissorCount (=%" PRIu32
2693 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2694 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002695 }
2696 }
2697
ziga-lunarg845883b2021-07-14 15:05:00 +02002698 if (!has_dynamic_scissor && viewport_state.pScissors) {
2699 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2700 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002701
2702 if (scissor.offset.x < 0) {
2703 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2704 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2705 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2706 scissor.offset.x, i, scissor_i);
2707 }
2708
2709 if (scissor.offset.y < 0) {
2710 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2711 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2712 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2713 scissor.offset.y, i, scissor_i);
2714 }
2715
ziga-lunarg845883b2021-07-14 15:05:00 +02002716 const int64_t x_sum =
2717 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2718 if (x_sum > std::numeric_limits<int32_t>::max()) {
2719 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2720 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2721 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2722 "] will overflow int32_t.",
2723 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2724 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002725
ziga-lunarg845883b2021-07-14 15:05:00 +02002726 const int64_t y_sum =
2727 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2728 if (y_sum > std::numeric_limits<int32_t>::max()) {
2729 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2730 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2731 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2732 "] will overflow int32_t.",
2733 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2734 }
2735 }
2736 }
2737
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002738 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002739 skip |=
2740 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2741 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2742 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2743 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002744 }
2745
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002746 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002747 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2748 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2749 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2750 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2751 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002752 }
2753
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002754 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2755 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2756 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2757 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2758 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2759 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2760 skip |= LogError(
2761 device, vuid,
2762 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2763 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2764 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2765 }
Petr Krausa6103552017-11-16 21:21:58 +01002766 }
2767
Dave Houlton142c4cb2018-10-17 15:04:41 -06002768 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002769 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002770 skip |=
2771 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2772 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2773 ") must be zero or identical to pCreateInfos[%" PRIu32
2774 "].pViewportState->viewportCount (=%" PRIu32 ").",
2775 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002776 }
2777
Dave Houlton142c4cb2018-10-17 15:04:41 -06002778 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002779 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002780 skip |= LogError(
2781 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002782 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2783 "] "
2784 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2785 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2786 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002787 }
2788
Petr Krausa6103552017-11-16 21:21:58 +01002789 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002790 skip |= LogError(
2791 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002792 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2793 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002794 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2795 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002796 }
2797
2798 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002799 skip |= LogError(
2800 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002801 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2802 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002803 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2804 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002805 }
2806
Jeff Bolz3e71f782018-08-29 23:15:45 -05002807 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002808 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2809 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2810 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002811 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002812 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2813 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2814 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2815 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002816 }
2817
Jeff Bolz9af91c52018-09-01 21:53:57 -05002818 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002819 shading_rate_image_struct->viewportCount > 0 &&
2820 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002822 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002823 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002824 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2825 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002826 i, i);
2827 }
2828
Chris Mayer328d8212018-12-11 14:16:18 +01002829 if (vp_swizzle_struct) {
2830 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002831 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2832 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2833 " does "
2834 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2835 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002836 }
2837 }
2838
Petr Krausb3fcdb42018-01-09 22:09:09 +01002839 // validate the VkViewports
2840 if (!has_dynamic_viewport && viewport_state.pViewports) {
2841 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2842 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002843 const char *fn_name = "vkCreateGraphicsPipelines";
2844 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2845 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2846 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002847 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002848 }
2849 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002850
sfricke-samsung45996a42021-09-16 13:45:27 -07002851 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002852 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2853 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2854 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2855 "VK_NV_clip_space_w_scaling extension is not enabled.",
2856 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002857 }
2858
sfricke-samsung45996a42021-09-16 13:45:27 -07002859 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2861 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2862 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2863 "VK_EXT_discard_rectangles extension is not enabled.",
2864 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002865 }
2866
sfricke-samsung45996a42021-09-16 13:45:27 -07002867 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002868 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2869 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2870 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2871 "VK_EXT_sample_locations extension is not enabled.",
2872 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002873 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002874
sfricke-samsung45996a42021-09-16 13:45:27 -07002875 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002876 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2877 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2878 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2879 "VK_NV_scissor_exclusive extension is not enabled.",
2880 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002881 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002882
2883 if (coarse_sample_order_struct &&
2884 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2885 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002886 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2887 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2888 "] "
2889 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2890 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2891 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002892 }
2893
2894 if (coarse_sample_order_struct) {
2895 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002896 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002897 }
2898 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002899
2900 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2901 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002902 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2903 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2904 "] "
2905 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2906 ") "
2907 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2908 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002909 }
2910 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002911 skip |= LogError(
2912 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002913 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2914 "] "
2915 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2916 i);
2917 }
2918 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002919
2920 if (depth_clip_control_struct) {
2921 const auto *depth_clip_control_features =
2922 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2923 const bool enabled_depth_clip_control =
2924 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2925 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2926 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2927 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2928 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2929 "depthClipControl feature is not enabled. ",
2930 i);
2931 }
2932 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002933 }
2934
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002935 const bool is_frag_out_graphics_lib =
2936 graphics_lib_info &&
2937 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002938 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002939 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002940 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2941 "].pRasterizationState->rasterizerDiscardEnable "
2942 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002943 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002945 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002946 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002947 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2948 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002949 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002950 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002951 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002953 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002954 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002955 skip |= validate_struct_pnext(
2956 "vkCreateGraphicsPipelines",
2957 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002958 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002959 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2960 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002962 skip |= validate_reserved_flags(
2963 "vkCreateGraphicsPipelines",
2964 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002965 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002966
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002967 skip |= validate_bool32(
2968 "vkCreateGraphicsPipelines",
2969 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002970 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002971
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002972 skip |= validate_array(
2973 "vkCreateGraphicsPipelines",
2974 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2975 ParameterName::IndexVector{i}),
2976 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002977 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2978 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002979
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002980 skip |= validate_flags("vkCreateGraphicsPipelines",
2981 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2982 ParameterName::IndexVector{i}),
2983 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002984 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002985 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002986
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002987 skip |= validate_bool32("vkCreateGraphicsPipelines",
2988 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2989 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002990 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002992 skip |= validate_bool32(
2993 "vkCreateGraphicsPipelines",
2994 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002995 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002996
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002997 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002998 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
2999 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3000 "].pMultisampleState->sType must be "
3001 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003002 i);
John Zulauf7acac592017-11-06 11:15:53 -07003003 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003004 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003005 if (!physical_device_features.sampleRateShading) {
3006 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
3007 "vkCreateGraphicsPipelines(): parameter "
3008 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
3009 i);
3010 }
3011 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
3012 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003013 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003014 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003015
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003016 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
3017 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
3018 "].pMultisampleState->minSampleShading.",
3019 i);
3020 }
John Zulauf7acac592017-11-06 11:15:53 -07003021 }
3022 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003023
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003024 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003025 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003026
3027 if (line_state) {
3028 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
3029 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003030 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003031 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3033 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003034 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003035 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003036 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003037 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003038 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003039 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3040 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003041 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003042 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003043 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003044 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003045 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003046 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3047 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003048 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003049 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003050 }
3051 }
3052 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3053 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3054 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003055 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003056 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3057 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 "range [1,256].",
3059 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003060 }
3061 }
3062 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003063 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003064 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3065 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003066 skip |=
3067 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003068 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3069 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003070 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3071 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003072 }
3073 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3074 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003075 skip |=
3076 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003077 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3078 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003079 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3080 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003081 }
3082 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3083 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003084 skip |=
3085 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003086 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3087 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003088 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3089 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003090 }
3091 if (line_state->stippledLineEnable) {
3092 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3093 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003094 skip |=
3095 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003096 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3097 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003098 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3099 "stippledRectangularLines feature.",
3100 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003101 }
3102 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3103 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003104 skip |=
3105 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003106 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3107 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003108 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3109 "stippledBresenhamLines feature.",
3110 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003111 }
3112 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3113 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003114 skip |=
3115 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003116 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3117 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003118 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3119 "stippledSmoothLines feature.",
3120 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003121 }
3122 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003123 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003124 skip |=
3125 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003126 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3127 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003128 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3129 "stippledRectangularLines and strictLines features.",
3130 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003131 }
3132 }
3133 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003134 }
3135
Petr Krause91f7a12017-12-14 20:57:36 +01003136 bool uses_color_attachment = false;
3137 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003138 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003139 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003140 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003141 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003142 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003143 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003144 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003145 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003146 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003147 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003148 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003149 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003150 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003151 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003152 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003153 }
3154
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003155 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003156 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003157 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003159 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003160 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161
Mike Schuchardt00e81452021-11-29 11:11:20 -08003162 skip |=
3163 validate_flags("vkCreateGraphicsPipelines",
3164 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3165 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003166 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003167 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168
3169 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003170 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003171 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003172 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173
3174 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003175 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003177 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003178
3179 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003180 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003181 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003182 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003183 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003184
3185 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003186 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003187 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003188 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003189
3190 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003191 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003192 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003193 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003194
3195 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003196 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003198 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003199 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003200
3201 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003202 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003203 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003204 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003205 "VUID-VkStencilOpState-passOp-parameter");
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.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003210 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003211 "VUID-VkStencilOpState-depthFailOp-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.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003216 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003217 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-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->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003222 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003223 "VUID-VkStencilOpState-failOp-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->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003228 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003229 "VUID-VkStencilOpState-passOp-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.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003234 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003235 "VUID-VkStencilOpState-depthFailOp-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.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003240 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003241 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003243 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003244 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003245 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3246 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003247 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3248 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003249 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003250
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003251 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003252 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3253 const auto *rasterization_order_attachment_access_feature =
3254 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3255 const bool rasterization_order_depth_attachment_access_feature_enabled =
3256 rasterization_order_attachment_access_feature &&
3257 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3258 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3259 skip |= LogError(
3260 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3261 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3262 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3263 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003264 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003265 }
3266
3267 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3268 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003269 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003270 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3271 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003272 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003273 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3274 }
3275 }
3276
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003277 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003278 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3279 const auto *rasterization_order_attachment_access_feature =
3280 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3281 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3282 rasterization_order_attachment_access_feature &&
3283 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3284 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3285 skip |= LogError(
3286 device,
3287 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3288 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3289 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3290 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003291 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003292 }
3293
3294 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3295 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003296 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003297 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3298 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003299 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003300 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3301 }
3302 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003303 }
3304
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003305 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003306 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3307 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003308
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003309 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3310 skip |=
3311 validate_struct_type("vkCreateGraphicsPipelines",
3312 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3313 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3314 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3315 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003316
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003317 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003318 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003319 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003320 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3321 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003322 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003323 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3324 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003325
Mike Schuchardt00e81452021-11-29 11:11:20 -08003326 skip |= validate_flags("vkCreateGraphicsPipelines",
3327 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3328 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003329 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003330 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003331
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003332 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003333 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3334 const auto *rasterization_order_attachment_access_feature =
3335 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3336 const bool rasterization_order_color_attachment_access_feature_enabled =
3337 rasterization_order_attachment_access_feature &&
3338 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3339
3340 if (!rasterization_order_color_attachment_access_feature_enabled) {
3341 skip |= LogError(
3342 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3343 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3344 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3345 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003346 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003347 }
3348
3349 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003350 skip |=
3351 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3352 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3353 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3354 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3355 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003356 }
3357 }
3358
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003359 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003360 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003361 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003362 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003363
3364 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003365 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3367 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003368 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3369 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003370
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003371 if (create_info.pColorBlendState->pAttachments != NULL) {
3372 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003373 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003374 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003375 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003376 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003377 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003378
3379 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003380 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003381 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003382 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003383 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003384 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003385 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003386
3387 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003388 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003389 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003390 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003391 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003392 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003393 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003394
3395 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003396 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003397 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003398 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003399 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003400 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003401 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003402
3403 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003404 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003405 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003406 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003407 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003408 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003409 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003410
3411 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003412 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003413 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003414 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003415 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003416 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003417 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003418
3419 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003420 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003421 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003422 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003423 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003424 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003425 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426
3427 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003428 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003430 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003431 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003432 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003433 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003434
3435 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3436 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003437 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003438 case VK_BLEND_OP_ZERO_EXT:
3439 case VK_BLEND_OP_SRC_EXT:
3440 case VK_BLEND_OP_DST_EXT:
3441 case VK_BLEND_OP_SRC_OVER_EXT:
3442 case VK_BLEND_OP_DST_OVER_EXT:
3443 case VK_BLEND_OP_SRC_IN_EXT:
3444 case VK_BLEND_OP_DST_IN_EXT:
3445 case VK_BLEND_OP_SRC_OUT_EXT:
3446 case VK_BLEND_OP_DST_OUT_EXT:
3447 case VK_BLEND_OP_SRC_ATOP_EXT:
3448 case VK_BLEND_OP_DST_ATOP_EXT:
3449 case VK_BLEND_OP_XOR_EXT:
3450 case VK_BLEND_OP_INVERT_EXT:
3451 case VK_BLEND_OP_INVERT_RGB_EXT:
3452 case VK_BLEND_OP_LINEARDODGE_EXT:
3453 case VK_BLEND_OP_LINEARBURN_EXT:
3454 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3455 case VK_BLEND_OP_LINEARLIGHT_EXT:
3456 case VK_BLEND_OP_PINLIGHT_EXT:
3457 case VK_BLEND_OP_HARDMIX_EXT:
3458 case VK_BLEND_OP_PLUS_EXT:
3459 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3460 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3461 case VK_BLEND_OP_PLUS_DARKER_EXT:
3462 case VK_BLEND_OP_MINUS_EXT:
3463 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3464 case VK_BLEND_OP_CONTRAST_EXT:
3465 case VK_BLEND_OP_INVERT_OVG_EXT:
3466 case VK_BLEND_OP_RED_EXT:
3467 case VK_BLEND_OP_GREEN_EXT:
3468 case VK_BLEND_OP_BLUE_EXT:
3469 invalid = true;
3470 break;
3471 default:
3472 break;
3473 }
3474 if (invalid) {
3475 skip |= LogError(
3476 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3477 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3478 "].pColorBlendState->pAttachments[%" PRIu32
3479 "].colorBlendOp (%s) is not valid when "
3480 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3481 "VK_FALSE",
3482 i, attachment_index,
3483 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003484 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003485 }
3486 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003487 }
3488 }
3489
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003490 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003491 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003492 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3493 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003494 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3495 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003496 }
3497
3498 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003499 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003500 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003501 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003502 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003503 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003504 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505 }
3506 }
3507 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003508
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003509 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003510 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003511 if (create_info.basePipelineIndex != -1) {
3512 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003513 skip |=
3514 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003515 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3516 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003517 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003518 "and pCreateInfos->basePipelineIndex is not -1.",
3519 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003520 }
3521 }
3522
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003523 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3524 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003525 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003526 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3527 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003528 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003529 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3530 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003531 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003532 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003533 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003534 skip |=
3535 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003536 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3537 ") must be a valid"
3538 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003539 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003540 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003541 }
3542 }
3543
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003544 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003545 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003546 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003547 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003548 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3549 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3550 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3551 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003552 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003553 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003554 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003555 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003556 "pCreateInfos[%" PRIu32
3557 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003558 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3559 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003560 }
3561 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003562 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3563 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003564 (physical_device_features.fillModeNonSolid == false)) {
3565 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003566 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3567 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003568 "pCreateInfos[%" PRIu32
3569 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003570 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3571 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003572 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003573 }
Petr Kraus299ba622017-11-24 03:09:03 +01003574
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003575 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003576 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003577 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3578 "The line width state is static (pCreateInfos[%" PRIu32
3579 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3580 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3581 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003582 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003583 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003584 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003585
3586 // Validate no flags not allowed are used
3587 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003588 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003589 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3590 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003591 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3592 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003593 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003594 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3595 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003596 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003597 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3598 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003599 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3600 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003601 }
3602 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3603 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003604 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3605 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003606 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3607 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003608 }
3609 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3610 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003611 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3612 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003613 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3614 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003615 }
3616 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3617 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003618 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3619 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003620 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3621 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003622 }
3623 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3624 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003625 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3626 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003627 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3628 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003629 }
3630 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3631 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003632 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3633 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003634 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3635 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003636 }
3637 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3638 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003639 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3640 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003641 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3642 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003643 }
3644 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3645 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003646 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3647 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003648 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3649 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003650 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003651 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3652 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3653 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3654 "]->flags (0x%x) must not include "
3655 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3656 i, flags);
3657 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003658 }
3659 }
3660
3661 return skip;
3662}
3663
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003664bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3665 uint32_t createInfoCount,
3666 const VkComputePipelineCreateInfo *pCreateInfos,
3667 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003668 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003669 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003670 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003671 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003672 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003673 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003674 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003675 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3676 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003677 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003678 skip |= LogError(
3679 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3680 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3681 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3682 feedback_count, i);
3683 }
Peter Chen85366392019-05-14 15:20:11 -04003684 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003685
3686 // Make sure compute stage is selected
3687 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003688 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003689 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3690 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003691 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003692 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003693
sfricke-samsungeb549012021-04-16 01:25:51 -07003694 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3695 // Validate no flags not allowed are used
3696 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003697 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3698 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3699 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3700 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003701 }
3702 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3703 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003704 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3705 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003706 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3707 i, flags);
3708 }
3709 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3710 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003711 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3712 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003713 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3714 i, flags);
3715 }
3716 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3717 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003718 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3719 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003720 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3721 i, flags);
3722 }
3723 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3724 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003725 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3726 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003727 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3728 i, flags);
3729 }
3730 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3731 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003732 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3733 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003734 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3735 i, flags);
3736 }
3737 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3738 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003739 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3740 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003741 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3742 i, flags);
3743 }
3744 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3745 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003746 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3747 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003748 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3749 i, flags);
3750 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003751 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3752 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003753 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3754 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003755 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3756 i, flags);
3757 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003758 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3759 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003760 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3761 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003762 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3763 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003764 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003765 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3766 if (pCreateInfos[i].basePipelineIndex != -1) {
3767 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3768 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3769 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3770 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3771 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3772 i);
3773 }
3774 }
3775
3776 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3777 if (pCreateInfos[i].basePipelineIndex != -1) {
3778 skip |= LogError(
3779 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3780 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3781 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3782 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3783 i);
3784 }
3785 } else {
3786 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3787 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3788 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3789 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3790 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3791 }
3792 }
3793 }
ziga-lunargc6341372021-07-28 12:57:42 +02003794
3795 std::stringstream msg;
3796 msg << "pCreateInfos[%" << i << "].stage";
3797 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003798 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003799 return skip;
3800}
3801
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003802bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003803 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003804 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003805
3806 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003807 const auto &features = physical_device_features;
3808 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003809
John Zulauf71968502017-10-26 13:51:15 -06003810 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3811 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003812 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3813 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3814 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3815 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003816 }
3817
3818 // Anistropy cannot be enabled in sampler unless enabled as a feature
3819 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003820 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3821 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3822 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003823 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003824 }
John Zulauf71968502017-10-26 13:51:15 -06003825
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003826 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3827 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003828 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3829 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3830 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3831 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003832 }
3833 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003834 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3835 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3836 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3837 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003838 }
3839 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003840 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3841 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3842 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3843 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003844 }
3845 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3846 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3847 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3848 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003849 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3850 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3851 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3852 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3853 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3854 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003855 }
3856 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003857 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3858 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3859 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003860 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003861 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003862 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3863 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3864 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003865 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003866 }
3867
3868 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003869 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003870 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003871 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3872 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003873 if (sampler_reduction != nullptr) {
3874 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003875 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3876 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
3877 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003878 }
3879 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003880 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003881 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003882 if (!IsExtEnabled(device_extensions.vk_ext_sampler_filter_minmax)) {
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003883 skip |= LogError(device, "VUID-VkSamplerCreateInfo-pNext-06726",
sjfricke751b7092022-04-12 21:49:37 +09003884 "vkCreateSampler(): sampler reduction mode is %s, but extension %s is not enabled.",
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003885 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3886 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
3887 }
ziga-lunarg01be97a2022-05-01 14:30:39 +02003888
3889 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
3890 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
3891 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
3892 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
3893 "extension %s is not enabled.",
3894 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3895 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
3896 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
3897 }
3898 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003899 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003900
3901 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3902 // valid VkBorderColor value
3903 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3904 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3905 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003906 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3907 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003908 }
3909
John Zulauf275805c2017-10-26 15:34:49 -06003910 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003911 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003912 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3913 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003914 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3915 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3916 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003917 }
3918 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003919
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003920 // Check for valid Lod range
3921 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003922 skip |=
3923 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3924 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003925 }
3926
3927 // Check mipLodBias to device limit
3928 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003929 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3930 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3931 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003932 }
3933
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003934 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003935 if (sampler_conversion != nullptr) {
3936 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3937 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3938 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3939 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003940 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003941 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003942 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3943 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3944 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3945 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3946 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3947 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3948 }
3949 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003950
3951 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3952 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3953 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3954 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3955 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3956 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3957 }
3958 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3959 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3960 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3961 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3962 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3963 }
3964 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3965 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3966 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3967 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3968 pCreateInfo->minLod, pCreateInfo->maxLod);
3969 }
3970 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3971 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3972 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3973 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3974 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3975 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3976 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3977 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3978 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3979 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3980 }
3981 if (pCreateInfo->anisotropyEnable) {
3982 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3983 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3984 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3985 }
3986 if (pCreateInfo->compareEnable) {
3987 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3988 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3989 "pCreateInfo->compareEnable must be VK_FALSE");
3990 }
3991 if (pCreateInfo->unnormalizedCoordinates) {
3992 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3993 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3994 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3995 }
3996 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003997
Piers Daniell833b9492021-11-20 11:47:10 -07003998 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3999 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
4000 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
4001 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4002 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
4003 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
4004 }
4005 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
4006 if (!custom_create_info) {
4007 skip |= LogError(
4008 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
4009 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
4010 "struct in pNext chain.\n",
4011 string_VkBorderColor(pCreateInfo->borderColor));
4012 } else {
4013 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
4014 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
4015 !FormatIsSampledInt(custom_create_info->format)) ||
4016 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
4017 !FormatIsSampledFloat(custom_create_info->format)))) {
4018 skip |=
4019 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06004020 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
4021 "whose type does not match\n",
4022 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07004023 ;
4024 }
4025 }
4026 }
4027
4028 const auto *border_color_component_mapping =
4029 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
4030 if (border_color_component_mapping) {
4031 const auto *border_color_swizzle_features =
4032 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4033 bool border_color_swizzle_features_enabled =
4034 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4035 if (!border_color_swizzle_features_enabled) {
4036 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4037 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4038 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004039 }
4040 }
4041 }
4042
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004043 return skip;
4044}
4045
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004046bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
4047 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4048 const char *func_name) const {
4049 bool skip = false;
4050
4051 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4052 uint32_t mutable_type_count = 0;
4053 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4054 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4055 }
4056 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4057 if (mutable_type_count == 0) {
4058 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4059 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4060 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4061 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4062 "].descriptorTypeCount is 0.",
4063 func_name, i, i);
4064 }
4065 } else {
4066 if (mutable_type_count > 0) {
4067 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4068 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4069 "].descriptorType is %s, but "
4070 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4071 "].descriptorTypeCount is not 0.",
4072 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4073 }
4074 }
4075 }
4076
4077 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4078 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4079 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
4080 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4081 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4082 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4083 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4084 func_name, j, k);
4085 break;
4086 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4087 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4088 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4089 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4090 func_name, j, k);
4091 break;
4092 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4093 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4094 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4095 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4096 func_name, j, k);
4097 break;
4098 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4099 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4100 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4101 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4102 func_name, j, k);
4103 break;
4104 default:
4105 break;
4106 }
4107 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4108 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4109 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4110 skip |=
4111 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4112 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4113 "].pDescriptorTypes[%" PRIu32
4114 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4115 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4116 func_name, j, k, j, l,
4117 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4118 }
4119 }
4120 }
4121 }
4122
4123 return skip;
4124}
4125
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004126bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4127 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4128 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004129 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004130 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004131
ziga-lunargfc6896f2021-10-15 18:46:12 +02004132 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4133 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4134 bool mutable_descriptor_type_features_enabled =
4135 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4136
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004137 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4138 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4139 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4140 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004141 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4142 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4143 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4144 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4145 ++descriptor_index) {
4146 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004147 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004148 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004149 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4150 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004151 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004152 }
4153 }
4154 }
4155
4156 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4157 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4158 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004159 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004160 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4161 "].descriptorCount is not 0, "
4162 "pCreateInfo->pBindings[%" PRIu32
4163 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004164 "values.",
4165 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004166 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004167
4168 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4169 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4170 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004171 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4172 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4173 "].descriptorCount is not 0 and "
4174 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4175 "].stageFlags "
4176 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4177 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004178 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004179
4180 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4181 if (!mutable_descriptor_type) {
4182 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4183 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4184 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4185 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4186 i);
4187 }
4188 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4189 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4190 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4191 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4192 "pImmutableSamplers is not NULL.",
4193 i);
4194 }
4195 if (!mutable_descriptor_type_features_enabled) {
4196 skip |= LogError(
4197 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4198 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4199 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4200 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4201 i);
4202 }
4203 }
4204
4205 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4206 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4207 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4208 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4209 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4210 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4211 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004212 }
4213 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004214
4215 if (mutable_descriptor_type) {
4216 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4217 "vkDescriptorSetLayoutCreateInfo");
4218 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004219 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004220 if (pCreateInfo) {
4221 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4222 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4223 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4224 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4225 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4226 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4227 }
4228 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4229 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4230 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4231 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4232 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4233 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4234 }
4235 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4236 !mutable_descriptor_type_features_enabled) {
4237 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4238 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4239 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4240 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4241 }
4242 }
4243
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004244 return skip;
4245}
4246
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004247bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4248 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004249 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004250 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4251 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4252 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004253 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4254 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004255}
4256
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004257bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4258 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004259 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004260 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004261
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004262 if (pDescriptorWrites != NULL) {
4263 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4264 // descriptorCount must be greater than 0
4265 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004266 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4267 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4268 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004269 }
4270
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004271 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004272 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004273 // dstSet must be a valid VkDescriptorSet handle
4274 skip |= validate_required_handle(vkCallingFunction,
4275 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4276 pDescriptorWrites[i].dstSet);
4277 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004278
4279 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4280 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4281 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4282 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4283 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004284 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004285 if (!isPushDescriptor) {
4286 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4287 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4288 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4289 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4290 // ObjectLifetimes::ValidateDescriptorWrite.
4291 skip |= LogError(
4292 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4293 "%s(): if pDescriptorWrites[%" PRIu32
4294 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4295 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4296 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4297 vkCallingFunction, i, i);
4298 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4299 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4300 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4301 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4302 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4303 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4304 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4305 "%s(): if pDescriptorWrites[%" PRIu32
4306 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4307 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4308 "].pImageInfo must not be NULL.",
4309 vkCallingFunction, i, i);
4310 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004311 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4312 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004313 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4314 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004315 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4316 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004317 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004318 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4319 ParameterName::IndexVector{i, descriptor_index}),
4320 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004321 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004322 }
4323 }
4324 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4325 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4326 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4327 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4328 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4329 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4330 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004331 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004332 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004333 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004334 "%s(): if pDescriptorWrites[%" PRIu32
4335 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004336 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4337 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004338 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004339 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004340 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004341 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004342 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004343 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004344 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4345 ++descriptor_index) {
4346 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4347 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4348 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004349 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004350 "%s(): if pDescriptorWrites[%" PRIu32
4351 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004352 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004353 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4354 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004355 }
4356 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004357 }
4358 }
4359 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4360 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004361 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004362 }
4363
4364 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4365 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004366 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004367 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4368 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004369 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004370 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004371 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004372 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004373 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004374 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004375 }
4376 }
4377 }
4378 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4379 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004380 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004381 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4382 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004383 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004384 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004385 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004386 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004387 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004388 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004389 }
4390 }
4391 }
4392 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004393 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4394 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004395 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004396 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004397 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4398 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4399 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4400 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004401 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004402 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4403 pDescriptorWrites[i].descriptorCount);
4404 }
4405 // further checks only if we have right structtype
4406 if (pnext_struct) {
4407 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4408 skip |= LogError(
4409 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004410 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4411 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004412 ".",
4413 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004414 }
sourav parmarbcee7512020-12-28 14:34:49 -08004415 if (pnext_struct->accelerationStructureCount == 0) {
4416 skip |= LogError(device,
4417 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004418 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004419 }
4420 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004421 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004422 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4423 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4424 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4425 skip |= LogError(device,
4426 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4427 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004428 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004429 }
4430 }
4431 }
sourav parmarbcee7512020-12-28 14:34:49 -08004432 }
4433 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004434 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004435 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4436 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4437 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4438 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004439 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004440 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4441 pDescriptorWrites[i].descriptorCount);
4442 }
4443 // further checks only if we have right structtype
4444 if (pnext_struct) {
4445 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4446 skip |= LogError(
4447 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004448 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4449 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004450 ".",
4451 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004452 }
sourav parmarbcee7512020-12-28 14:34:49 -08004453 if (pnext_struct->accelerationStructureCount == 0) {
4454 skip |= LogError(device,
4455 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004456 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004457 }
4458 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004459 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004460 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4461 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4462 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4463 skip |= LogError(device,
4464 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4465 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004466 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004467 }
4468 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004469 }
4470 }
4471 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004472 }
4473 }
4474 return skip;
4475}
4476
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004477bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4478 const VkWriteDescriptorSet *pDescriptorWrites,
4479 uint32_t descriptorCopyCount,
4480 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004481 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004482}
4483
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004484bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004485 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004486 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004487 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4488}
4489
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004490bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4491 const VkAllocationCallbacks *pAllocator,
4492 VkRenderPass *pRenderPass) const {
4493 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4494}
4495
Mike Schuchardt2df08912020-12-15 16:28:09 -08004496bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *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_2);
4500}
4501
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004502bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4503 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004504 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004505 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004506
4507 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4508 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4509 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004510 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4511 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004512 return skip;
4513}
4514
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004515bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004516 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004517 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004518
4519 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4520 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004521 bool cb_is_secondary;
4522 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004523 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004524 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4525 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004526
Tony-LunarG3c287f62020-12-17 12:39:49 -07004527 if (cb_is_secondary) {
4528 // Implicit VUs
4529 // validate only sType here; pointer has to be validated in core_validation
4530 const bool k_not_required = false;
4531 const char *k_no_vuid = nullptr;
4532 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4533 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004534 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4535 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004536
Tony-LunarG3c287f62020-12-17 12:39:49 -07004537 if (info) {
4538 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004539 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004540 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4541 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004542 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004543 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004544 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4545 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4546 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4547 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004548
Tony-LunarG3c287f62020-12-17 12:39:49 -07004549 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004550
Tony-LunarG3c287f62020-12-17 12:39:49 -07004551 // Explicit VUs
4552 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004553 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004554 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4555 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4556 cmd_name);
4557 }
4558
4559 if (physical_device_features.inheritedQueries) {
4560 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004561 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4562 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4563 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004564 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004565 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004566 }
4567
4568 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004569 skip |=
4570 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4571 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4572 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4573 } else { // !pipelineStatisticsQuery
4574 skip |=
4575 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4576 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004577 }
4578
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004579 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004580 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004581 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004582 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4583 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4584 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004585 commandBuffer,
4586 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004587 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4588 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4589 }
Petr Kraus139757b2019-08-15 17:19:33 +02004590 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004591
4592 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4593 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4594 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4595 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4596 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4597 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4598 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4599 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4600 }
Petr Kraus139757b2019-08-15 17:19:33 +02004601 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004602 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004603 return skip;
4604}
4605
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004606bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004607 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004608 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004609
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004610 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004611 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004612 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4613 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4614 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004615 }
4616 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004617 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4618 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4619 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004620 }
4621 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004622 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004623 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004624 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4625 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4626 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4627 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004628 }
4629 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004630
4631 if (pViewports) {
4632 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4633 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004634 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004635 skip |= manual_PreCallValidateViewport(
4636 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004637 }
4638 }
4639
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004640 return skip;
4641}
4642
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004643bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004644 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004645 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004646
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004647 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004648 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004649 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4650 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4651 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004652 }
4653 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004654 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4655 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4656 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004657 }
4658 } else { // multiViewport enabled
4659 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004660 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004661 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4662 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4663 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4664 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004665 }
4666 }
4667
Petr Kraus6260f0a2018-02-27 21:15:55 +01004668 if (pScissors) {
4669 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4670 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004671
Petr Kraus6260f0a2018-02-27 21:15:55 +01004672 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004673 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4674 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4675 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004676 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004677
Petr Kraus6260f0a2018-02-27 21:15:55 +01004678 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004679 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4680 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4681 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004682 }
4683
4684 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4685 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004686 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4687 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4688 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4689 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004690 }
4691
4692 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4693 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004694 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4695 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4696 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4697 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004698 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004699 }
4700 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004701
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004702 return skip;
4703}
4704
Jeff Bolz5c801d12019-10-09 10:38:45 -05004705bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004706 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004707
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004708 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004709 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4710 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004711 }
4712
4713 return skip;
4714}
4715
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004716bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004717 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004718 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004719
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004720 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004721 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004722 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4723 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004724 }
4725 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004726 skip |=
4727 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4728 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4729 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004730 }
4731 return skip;
4732}
4733
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004734bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004735 VkDeviceSize offset, uint32_t drawCount,
4736 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004737 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004738 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004739 skip |=
4740 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4741 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4742 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004743 }
4744 if (drawCount > device_limits.maxDrawIndirectCount) {
4745 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004746 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4747 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004748 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004749 }
4750 return skip;
4751}
4752
sfricke-samsungf692b972020-05-02 08:00:45 -07004753bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4754 VkDeviceSize countBufferOffset, bool khr) const {
4755 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004756 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004757 if (offset & 3) {
4758 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004759 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004760 }
4761
4762 if (countBufferOffset & 3) {
4763 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004764 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004765 countBufferOffset);
4766 }
4767 return skip;
4768}
4769
4770bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4771 VkDeviceSize offset, VkBuffer countBuffer,
4772 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4773 uint32_t stride) const {
4774 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4775}
4776
4777bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4778 VkDeviceSize offset, VkBuffer countBuffer,
4779 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4780 uint32_t stride) const {
4781 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4782}
4783
4784bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4785 VkDeviceSize countBufferOffset, bool khr) const {
4786 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004787 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004788 if (offset & 3) {
4789 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004790 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004791 }
4792
4793 if (countBufferOffset & 3) {
4794 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004795 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004796 countBufferOffset);
4797 }
4798 return skip;
4799}
4800
4801bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4802 VkDeviceSize offset, VkBuffer countBuffer,
4803 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4804 uint32_t stride) const {
4805 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4806}
4807
4808bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4809 VkDeviceSize offset, VkBuffer countBuffer,
4810 VkDeviceSize countBufferOffset,
4811 uint32_t maxDrawCount, uint32_t stride) const {
4812 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4813}
4814
Tony-LunarG4490de42021-06-21 15:49:19 -06004815bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4816 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4817 uint32_t firstInstance, uint32_t stride) const {
4818 bool skip = false;
4819 if (stride & 3) {
4820 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4821 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4822 }
4823 if (drawCount && nullptr == pVertexInfo) {
4824 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4825 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4826 "one or more valid instances of VkMultiDrawInfoEXT structures");
4827 }
4828 return skip;
4829}
4830
4831bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4832 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4833 uint32_t instanceCount, uint32_t firstInstance,
4834 uint32_t stride, const int32_t *pVertexOffset) const {
4835 bool skip = false;
4836 if (stride & 3) {
4837 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4838 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4839 }
4840 if (drawCount && nullptr == pIndexInfo) {
4841 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4842 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4843 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4844 }
4845 return skip;
4846}
4847
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004848bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4849 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004850 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004851 bool skip = false;
4852 for (uint32_t rect = 0; rect < rectCount; rect++) {
4853 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004854 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004855 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004856 }
sfricke-samsung10867682020-04-25 02:20:39 -07004857 if (pRects[rect].rect.extent.width == 0) {
4858 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004859 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004860 }
4861 if (pRects[rect].rect.extent.height == 0) {
4862 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004863 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004864 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004865 }
4866 return skip;
4867}
4868
Andrew Fobel3abeb992020-01-20 16:33:22 -05004869bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4870 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4871 VkImageFormatProperties2 *pImageFormatProperties,
4872 const char *apiName) const {
4873 bool skip = false;
4874
4875 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004876 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004877 if (image_stencil_struct != nullptr) {
4878 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4879 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4880 // No flags other than the legal attachment bits may be set
4881 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4882 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004883 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4884 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4885 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4886 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4887 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004888 }
4889 }
4890 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004891 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4892 if (image_drm_format) {
4893 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4894 skip |= LogError(
4895 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4896 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4897 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4898 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4899 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004900 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4901 skip |= LogError(
4902 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4903 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4904 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4905 apiName, image_drm_format->queueFamilyIndexCount);
4906 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004907 } else {
4908 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4909 skip |= LogError(
4910 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4911 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4912 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4913 apiName);
4914 }
4915 }
4916 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4917 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4918 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4919 if (!format_list || format_list->viewFormatCount == 0) {
4920 skip |= LogError(
4921 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4922 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4923 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4924 apiName);
4925 }
4926 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004927 }
4928
4929 return skip;
4930}
4931
4932bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4933 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4934 VkImageFormatProperties2 *pImageFormatProperties) const {
4935 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4936 "vkGetPhysicalDeviceImageFormatProperties2");
4937}
4938
4939bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4940 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4941 VkImageFormatProperties2 *pImageFormatProperties) const {
4942 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4943 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4944}
4945
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004946bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4947 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4948 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4949 bool skip = false;
4950
4951 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4952 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4953 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4954 }
4955
4956 return skip;
4957}
4958
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004959bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4960 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4961 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4962 bool skip = false;
4963
4964 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4965 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4966 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4967 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4968 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4969 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4970 }
4971
ziga-lunarg42f884b2021-08-25 16:13:20 +02004972 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004973}
4974
sfricke-samsung3999ef62020-02-09 17:05:59 -08004975bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4976 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4977 bool skip = false;
4978
4979 if (pRegions != nullptr) {
4980 for (uint32_t i = 0; i < regionCount; i++) {
4981 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004982 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004983 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004984 }
4985 }
4986 }
4987 return skip;
4988}
4989
Jeff Leger178b1e52020-10-05 12:22:23 -04004990bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4991 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4992 bool skip = false;
4993
4994 if (pCopyBufferInfo->pRegions != nullptr) {
4995 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4996 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004997 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004998 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004999 }
5000 }
5001 }
5002 return skip;
5003}
5004
Tony-LunarGef035472021-11-02 10:23:33 -06005005bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
5006 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
5007 bool skip = false;
5008
5009 if (pCopyBufferInfo->pRegions != nullptr) {
5010 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5011 if (pCopyBufferInfo->pRegions[i].size == 0) {
5012 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
5013 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
5014 }
5015 }
5016 }
5017 return skip;
5018}
5019
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005020bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005021 VkDeviceSize dstOffset, VkDeviceSize dataSize,
5022 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005023 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005024
5025 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005026 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5027 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5028 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005029 }
5030
5031 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005032 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5033 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5034 "), must be greater than zero and less than or equal to 65536.",
5035 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005036 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005037 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5038 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5039 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005040 }
5041 return skip;
5042}
5043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005044bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005045 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005046 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005047
5048 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005049 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5050 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5051 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005052 }
5053
5054 if (size != VK_WHOLE_SIZE) {
5055 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005056 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005057 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5058 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005059 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005060 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5061 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005062 }
5063 }
5064 return skip;
5065}
5066
sfricke-samsunga1d00272021-03-10 21:37:41 -08005067bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005068 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005069
5070 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005071 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5072 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5073 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5074 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005075 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005076 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5077 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5078 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005079 }
5080
5081 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5082 // queueFamilyIndexCount uint32_t values
5083 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005084 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005085 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005086 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005087 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5088 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005089 }
5090 }
5091
Dave Houlton413a6782018-05-22 13:01:54 -06005092 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005093 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005094
sfricke-samsunga1d00272021-03-10 21:37:41 -08005095 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5096 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5097 if (format_list_info) {
5098 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5099 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5100 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5101 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005102 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5103 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005104 func_name, viewFormatCount);
5105 }
5106
5107 // Using the first format, compare the rest of the formats against it that they are compatible
5108 for (uint32_t i = 1; i < viewFormatCount; i++) {
5109 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5110 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5111 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5112 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005113 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5114 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005115 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5116 string_VkFormat(format_list_info->pViewFormats[i]));
5117 }
5118 }
5119 }
5120
5121 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5122 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5123 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5124 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5125 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5126 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5127 func_name);
5128 } else {
5129 if (format_list_info == nullptr) {
5130 skip |= LogError(
5131 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5132 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5133 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5134 func_name);
5135 } else if (format_list_info->viewFormatCount == 0) {
5136 skip |= LogError(
5137 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5138 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5139 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5140 func_name);
5141 } else {
5142 bool found_base_format = false;
5143 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5144 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5145 found_base_format = true;
5146 break;
5147 }
5148 }
5149 if (!found_base_format) {
5150 skip |=
5151 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5152 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5153 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5154 "pCreateInfo->imageFormat.",
5155 func_name);
5156 }
5157 }
5158 }
5159 }
5160 }
5161 return skip;
5162}
5163
5164bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5165 const VkAllocationCallbacks *pAllocator,
5166 VkSwapchainKHR *pSwapchain) const {
5167 bool skip = false;
5168 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5169 return skip;
5170}
5171
5172bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5173 const VkSwapchainCreateInfoKHR *pCreateInfos,
5174 const VkAllocationCallbacks *pAllocator,
5175 VkSwapchainKHR *pSwapchains) const {
5176 bool skip = false;
5177 if (pCreateInfos) {
5178 for (uint32_t i = 0; i < swapchainCount; i++) {
5179 std::stringstream func_name;
5180 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5181 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5182 }
5183 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005184 return skip;
5185}
5186
Jeff Bolz5c801d12019-10-09 10:38:45 -05005187bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005188 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005189
5190 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005191 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005192 if (present_regions) {
5193 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005194 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005195 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5196 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005197 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005198 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5199 "extension swapchainCount is %i. These values must be equal.",
5200 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005201 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005202 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005203 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5204 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005205 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5206 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5207 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005208 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005209 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005210 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005211 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005212 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005213 }
5214 }
5215
5216 return skip;
5217}
5218
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005219bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5220 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5221 const VkAllocationCallbacks *pAllocator,
5222 VkDisplayModeKHR *pMode) const {
5223 bool skip = false;
5224
5225 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5226 if (display_mode_parameters.visibleRegion.width == 0) {
5227 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5228 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5229 }
5230 if (display_mode_parameters.visibleRegion.height == 0) {
5231 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5232 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5233 }
5234 if (display_mode_parameters.refreshRate == 0) {
5235 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5236 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5237 }
5238
5239 return skip;
5240}
5241
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005242#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005243bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5244 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5245 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005246 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005247 bool skip = false;
5248
5249 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005250 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5251 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005252 }
5253
5254 return skip;
5255}
5256#endif // VK_USE_PLATFORM_WIN32_KHR
5257
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005258static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5259 bool partial_overlap = false;
5260
5261 static const std::vector<VkDescriptorType> all_descriptor_types = {
5262 VK_DESCRIPTOR_TYPE_SAMPLER,
5263 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5264 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5265 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5266 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5267 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5268 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5269 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5270 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5271 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5272 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5273 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5274 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5275 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5276 };
5277
5278 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5279 if (mutable_descriptor_type) {
5280 std::vector<VkDescriptorType> first_types, second_types;
5281 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5282 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5283 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5284 }
5285 } else {
5286 first_types = all_descriptor_types;
5287 }
5288 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5289 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5290 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5291 }
5292 } else {
5293 second_types = all_descriptor_types;
5294 }
5295
5296 bool complete_overlap = first_types.size() == second_types.size();
5297 bool disjoint = true;
5298 for (const auto first_type : first_types) {
5299 bool found = false;
5300 for (const auto second_type : second_types) {
5301 if (first_type == second_type) {
5302 found = true;
5303 break;
5304 }
5305 }
5306 if (found) {
5307 disjoint = false;
5308 } else {
5309 complete_overlap = false;
5310 }
5311 if (!disjoint && !complete_overlap) {
5312 partial_overlap = true;
5313 break;
5314 }
5315 }
5316 }
5317
5318 return partial_overlap;
5319}
5320
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005321bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005322 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005323 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005324 bool skip = false;
5325
5326 if (pCreateInfo) {
5327 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005328 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5329 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005330 }
5331
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005332 const auto *mutable_descriptor_type_features =
5333 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5334 bool mutable_descriptor_type_enabled =
5335 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5336
Petr Krausc8655be2017-09-27 18:56:51 +02005337 if (pCreateInfo->pPoolSizes) {
5338 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5339 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005340 skip |= LogError(
5341 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005342 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005343 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005344 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5345 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005346 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5347 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5348 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5349 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5350 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005351 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005352 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5353 skip |=
5354 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5355 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5356 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5357 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5358 i);
5359 }
5360 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5361 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5362 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5363 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5364 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5365 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5366 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5367 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5368 " and have sets which partially overlap.",
5369 i, j);
5370 }
5371 }
5372 }
5373 }
Petr Krausc8655be2017-09-27 18:56:51 +02005374 }
5375 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005376
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005377 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5378 skip |=
5379 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5380 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5381 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5382 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005383 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5384 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5385 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5386 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5387 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5388 }
Petr Krausc8655be2017-09-27 18:56:51 +02005389 }
5390
5391 return skip;
5392}
5393
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005394bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005395 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005396 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005397
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005398 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005399 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005400 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5401 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5402 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005403 }
5404
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005405 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005406 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005407 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5408 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5409 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005410 }
5411
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005412 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005413 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005414 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5415 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5416 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005417 }
5418
5419 return skip;
5420}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005421
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005422bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005423 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005424 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005425
5426 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005427 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5428 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005429 }
5430 return skip;
5431}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005432
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005433bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5434 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005435 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005436 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005437
5438 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005439 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005440 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005441 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5442 "vkCmdDispatch(): baseGroupX (%" PRIu32
5443 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5444 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005445 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005446 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5447 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5448 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5449 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005450 }
5451
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005452 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005453 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005454 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5455 "vkCmdDispatch(): baseGroupY (%" PRIu32
5456 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5457 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005458 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005459 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5460 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5461 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5462 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005463 }
5464
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005465 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005466 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005467 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5468 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5469 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5470 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005471 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005472 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5473 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5474 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5475 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005476 }
5477
5478 return skip;
5479}
5480
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005481bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5482 VkPipelineBindPoint pipelineBindPoint,
5483 VkPipelineLayout layout, uint32_t set,
5484 uint32_t descriptorWriteCount,
5485 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005486 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005487}
5488
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005489bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5490 uint32_t firstExclusiveScissor,
5491 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005492 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005493 bool skip = false;
5494
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005495 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005496 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005497 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005498 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5499 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5500 ") is not 0.",
5501 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005502 }
5503 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005504 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005505 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5506 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5507 ") is not 1.",
5508 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005509 }
5510 } else { // multiViewport enabled
5511 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005512 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005513 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5514 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5515 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5516 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005517 }
5518 }
5519
Jeff Bolz3e71f782018-08-29 23:15:45 -05005520 if (pExclusiveScissors) {
5521 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5522 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5523
5524 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005525 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5526 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5527 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005528 }
5529
5530 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005531 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5532 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5533 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005534 }
5535
5536 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5537 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005538 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5539 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5540 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5541 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005542 }
5543
5544 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5545 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005546 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5547 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5548 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5549 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005550 }
5551 }
5552 }
5553
5554 return skip;
5555}
5556
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005557bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5558 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005559 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005560 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005561 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5562 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5563 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5564 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5565 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5566 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005567 }
5568
5569 return skip;
5570}
5571
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005572bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5573 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005574 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005575 bool skip = false;
5576
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005577 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005578 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005579 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005580 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5581 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5582 ") is not 0.",
5583 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005584 }
5585 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005586 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005587 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5588 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5589 ") is not 1.",
5590 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005591 }
5592 }
5593
Jeff Bolz9af91c52018-09-01 21:53:57 -05005594 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005595 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005596 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5597 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5598 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5599 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005600 }
5601
5602 return skip;
5603}
5604
Jeff Bolz5c801d12019-10-09 10:38:45 -05005605bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5606 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5607 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005608 bool skip = false;
5609
Dave Houlton142c4cb2018-10-17 15:04:41 -06005610 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005611 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5612 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5613 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005614 }
5615
5616 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005617 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005618 }
5619
5620 return skip;
5621}
5622
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005623bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005624 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005625 bool skip = false;
5626
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005627 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005628 skip |= LogError(
5629 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005630 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5631 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005632 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005633 }
5634
5635 return skip;
5636}
5637
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005638bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5639 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005640 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005641 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005642 static const int condition_multiples = 0b0011;
5643 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005644 skip |= LogError(
5645 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005646 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005647 }
Lockee1c22882019-06-10 16:02:54 -06005648 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005649 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5650 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5651 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5652 stride);
Lockee1c22882019-06-10 16:02:54 -06005653 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005654 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005655 skip |= LogError(
5656 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005657 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5658 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005659 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005660 if (drawCount > device_limits.maxDrawIndirectCount) {
5661 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005662 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5663 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005664 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005665 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005666 return skip;
5667}
5668
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005669bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5670 VkDeviceSize offset, VkBuffer countBuffer,
5671 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005672 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005673 bool skip = false;
5674
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005675 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005676 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5677 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5678 "), is not a multiple of 4.",
5679 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005680 }
5681
5682 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005683 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5684 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5685 "), is not a multiple of 4.",
5686 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005687 }
5688
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005689 return skip;
5690}
5691
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005692bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005693 const VkAllocationCallbacks *pAllocator,
5694 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005695 bool skip = false;
5696
5697 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5698 if (pCreateInfo != nullptr) {
5699 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5700 // VkQueryPipelineStatisticFlagBits values
5701 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5702 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005703 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5704 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5705 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5706 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005707 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005708 if (pCreateInfo->queryCount == 0) {
5709 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5710 "vkCreateQueryPool(): queryCount must be greater than zero.");
5711 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005712 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005713 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005714}
5715
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005716bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5717 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005718 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005719 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5720 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005721}
5722
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005723void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005724 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5725 VkResult result) {
5726 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005727 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005728}
5729
Mike Schuchardt2df08912020-12-15 16:28:09 -08005730void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005731 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5732 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005733 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005734 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005735 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005736}
5737
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005738void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5739 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005740 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005741 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005742 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005743}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005744
Tony-LunarG3c287f62020-12-17 12:39:49 -07005745void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005746 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005747 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005748 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005749 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005750 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005751 }
5752 }
5753}
5754
5755void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005756 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005757 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005758 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5759 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5760 }
5761}
5762
5763void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005764 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005765 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005766 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5767 if (item->second == commandPool) {
5768 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005769 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005770 ++item;
5771 }
5772 }
5773}
5774
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005775bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005776 const VkAllocationCallbacks *pAllocator,
5777 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005778 bool skip = false;
5779
5780 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005781 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005782 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005783 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5784 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005785 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005786
5787 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005788 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005789 if (flags_info) {
5790 flags = flags_info->flags;
5791 }
5792
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005793 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005794 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005795 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005796 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5797 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005798 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005799 }
5800
5801#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005802 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005803#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005804 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5805 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005806#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005807 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005808#endif
5809
5810 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005811 skip |= LogError(
5812 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005813 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5814 }
5815 if (
5816#ifdef VK_USE_PLATFORM_WIN32_KHR
5817 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5818#endif
5819 (import_memory_fd && import_memory_fd->handleType) ||
5820#ifdef VK_USE_PLATFORM_ANDROID_KHR
5821 (import_memory_ahb && import_memory_ahb->buffer) ||
5822#endif
5823 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005824 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5825 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005826 }
5827 }
5828
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005829 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5830 if (export_memory) {
5831 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5832 if (export_memory_nv) {
5833 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5834 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5835 "VkExportMemoryAllocateInfoNV");
5836 }
5837#ifdef VK_USE_PLATFORM_WIN32_KHR
5838 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5839 if (export_memory_win32_nv) {
5840 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5841 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5842 "VkExportMemoryWin32HandleInfoNV");
5843 }
5844#endif
5845 }
5846
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005847 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005848 VkBool32 capture_replay = false;
5849 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005850 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005851 if (vulkan_12_features) {
5852 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5853 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5854 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005855 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005856 if (bda_features) {
5857 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5858 buffer_device_address = bda_features->bufferDeviceAddress;
5859 }
5860 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005861 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005862 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005863 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005864 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005865 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005866 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005867 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005868 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005869 }
5870 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005871 }
5872 return skip;
5873}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005874
Jason Macnak192fa0e2019-07-26 15:07:16 -07005875bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005876 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005877 bool skip = false;
5878
5879 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5880 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5881 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005882 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005883 } else {
5884 uint32_t vertex_component_size = 0;
5885 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5886 vertex_component_size = 4;
5887 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5888 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5889 vertex_component_size = 2;
5890 }
5891 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005892 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005893 }
5894 }
5895
5896 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5897 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005898 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005899 } else {
5900 uint32_t index_element_size = 0;
5901 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5902 index_element_size = 4;
5903 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5904 index_element_size = 2;
5905 }
5906 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005907 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005908 }
5909 }
5910 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5911 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005912 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005913 }
5914 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005915 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005916 }
5917 }
5918
5919 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005920 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005921 }
5922
5923 return skip;
5924}
5925
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005926bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5927 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005928 bool skip = false;
5929
5930 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005931 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005932 }
5933 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005934 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005935 }
5936
5937 return skip;
5938}
5939
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005940bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5941 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005942 bool skip = false;
5943 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005944 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005945 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005946 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005947 }
5948 return skip;
5949}
5950
5951bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005952 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005953 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005954 bool skip = false;
5955 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005956 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5957 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5958 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005959 }
5960 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005961 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5962 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5963 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005964 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005965 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5966 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5967 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5968 }
Jason Macnak5c954952019-07-09 15:46:12 -07005969 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5970 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005971 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5972 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5973 "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 -07005974 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005975 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005976 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005977 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5978 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005979 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5980 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005981 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005982 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005983 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5984 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5985 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005986 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005987 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005988 uint64_t total_triangle_count = 0;
5989 for (uint32_t i = 0; i < info.geometryCount; i++) {
5990 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005991
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005992 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005993
Jason Macnak5c954952019-07-09 15:46:12 -07005994 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5995 continue;
5996 }
5997 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5998 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005999 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006000 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
6001 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
6002 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006003 }
6004 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006005 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
6006 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
6007 for (uint32_t i = 1; i < info.geometryCount; i++) {
6008 const VkGeometryNV &geometry = info.pGeometries[i];
6009 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006010 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006011 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
6012 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006013 "info.pGeometries[0].geometryType.",
6014 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07006015 }
6016 }
6017 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006018 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
6019 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
6020 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
6021 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
6022 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
6023 "or VK_GEOMETRY_TYPE_AABBS_NV.");
6024 }
6025 }
6026 skip |=
6027 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006028 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006029 return skip;
6030}
6031
Ricardo Garciaa4935972019-02-21 17:43:18 +01006032bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6033 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006034 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006035 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006036 if (pCreateInfo) {
6037 if ((pCreateInfo->compactedSize != 0) &&
6038 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006039 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6040 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6041 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6042 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006043 }
Jason Macnak5c954952019-07-09 15:46:12 -07006044
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006045 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006046 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006047 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006048 return skip;
6049}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006050
Jeff Bolz5c801d12019-10-09 10:38:45 -05006051bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6052 const VkAccelerationStructureInfoNV *pInfo,
6053 VkBuffer instanceData, VkDeviceSize instanceOffset,
6054 VkBool32 update, VkAccelerationStructureNV dst,
6055 VkAccelerationStructureNV src, VkBuffer scratch,
6056 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006057 bool skip = false;
6058
6059 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006060 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006061 }
6062
6063 return skip;
6064}
6065
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006066bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6067 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6068 VkAccelerationStructureKHR *pAccelerationStructure) const {
6069 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006070 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006071 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006072 if (!acceleration_structure_features ||
6073 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6074 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6075 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6076 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006077 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006078 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6079 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006080 (acceleration_structure_features &&
6081 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006082 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006083 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6084 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6085 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6086 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006087 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006088 if (pCreateInfo->deviceAddress &&
6089 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6090 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6091 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6092 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6093 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006094 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6095 (acceleration_structure_features &&
6096 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6097 skip |= LogError(
6098 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6099 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6100 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6101 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006102 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6103 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006104 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6105 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006106 }
sourav parmar83c31b12020-05-06 12:30:54 -07006107 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006108 return skip;
6109}
6110
Jason Macnak5c954952019-07-09 15:46:12 -07006111bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6112 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006113 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006114 bool skip = false;
6115 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006116 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6117 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006118 }
6119 return skip;
6120}
6121
sourav parmarcd5fb182020-07-17 12:58:44 -07006122bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6123 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6124 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6125 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006126 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006127 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006128 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006129 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006130 }
6131 return skip;
6132}
6133
Peter Chen85366392019-05-14 15:20:11 -04006134bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6135 uint32_t createInfoCount,
6136 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6137 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006138 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006139 bool skip = false;
6140
6141 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006142 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6143 std::stringstream msg;
6144 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6145 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6146 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006147 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006148 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006149 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006150 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6151 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6152 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6153 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006154 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006155
6156 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006157 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006158 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6159 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6160 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6161 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6162 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6163 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6164 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6165 }
6166 }
6167
sourav parmarf4a78252020-04-10 13:04:21 -07006168 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6169 skip |=
6170 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6171 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6172 }
6173 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6174 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6175 skip |=
6176 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6177 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6178 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6179 }
6180 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6181 if (pCreateInfos[i].basePipelineIndex != -1) {
6182 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6183 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6184 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6185 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6186 "and pCreateInfos->basePipelineIndex is not -1.");
6187 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006188 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006189 skip |=
6190 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6191 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6192 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6193 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6194 "that element.");
6195 }
sourav parmarf4a78252020-04-10 13:04:21 -07006196 }
6197 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006198 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006199 skip |=
6200 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6201 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6202 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6203 "commands pCreateInfos parameter.");
6204 }
6205 } else {
6206 if (pCreateInfos[i].basePipelineIndex != -1) {
6207 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6208 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6209 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6210 }
6211 }
6212 }
6213 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6214 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6215 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6216 }
6217 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6218 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6219 "vkCreateRayTracingPipelinesNV: flags must not include "
6220 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6221 }
6222 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6223 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6224 "vkCreateRayTracingPipelinesNV: flags must not include "
6225 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6226 }
6227 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6228 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6229 "vkCreateRayTracingPipelinesNV: flags must not include "
6230 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6231 }
6232 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6233 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6234 "vkCreateRayTracingPipelinesNV: flags must not include "
6235 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6236 }
6237 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6238 skip |= LogError(
6239 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6240 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6241 }
6242 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6243 skip |= LogError(
6244 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6245 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6246 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006247 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6248 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6249 "vkCreateRayTracingPipelinesNV: flags must not include "
6250 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6251 }
6252 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6253 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6254 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6255 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006256 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6257 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6258 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6259 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6260 }
Peter Chen85366392019-05-14 15:20:11 -04006261 }
6262
6263 return skip;
6264}
6265
sourav parmarcd5fb182020-07-17 12:58:44 -07006266bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6267 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6268 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006269 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006270 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006271 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6272 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6273 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006274 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006275 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006276 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6277 std::stringstream msg;
6278 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6279 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006280 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006281 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006282 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6283 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6284 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6285 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6286 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6287 }
6288 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6289 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6290 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6291 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6292 }
6293 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006294 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006295 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006296 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006297 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6298 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6299 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006300 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6301 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6302 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006303 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006304 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006305 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6306 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6307 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6308 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006309 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006310 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6311 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6312 }
6313 }
sourav parmarf4a78252020-04-10 13:04:21 -07006314 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006315 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6316 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006317 }
6318 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006319 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006320 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006321 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6322 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006323 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006324 }
6325 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6326 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6327 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006328 }
6329 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6330 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6331 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6332 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6333 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6334 skip |= LogError(
6335 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006336 "vkCreateRayTracingPipelinesKHR: If flags includes "
6337 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006338 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6339 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6340 "must not be VK_SHADER_UNUSED_KHR");
6341 }
6342 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6343 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6344 skip |= LogError(
6345 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006346 "vkCreateRayTracingPipelinesKHR: If flags includes "
6347 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006348 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6349 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6350 "element must not be VK_SHADER_UNUSED_KHR");
6351 }
6352 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006353 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6354 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6355 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6356 skip |= LogError(
6357 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6358 "vkCreateRayTracingPipelinesKHR: If "
6359 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6360 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6361 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6362 }
6363 }
sourav parmarf4a78252020-04-10 13:04:21 -07006364 }
6365 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6366 if (pCreateInfos[i].basePipelineIndex != -1) {
6367 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6368 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006369 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006370 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6371 "and pCreateInfos->basePipelineIndex is not -1.");
6372 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006373 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006374 skip |=
6375 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6376 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6377 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6378 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6379 "element.");
6380 }
sourav parmarf4a78252020-04-10 13:04:21 -07006381 }
6382 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006383 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006384 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006385 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006386 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6387 ") must be a valid into the calling"
6388 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006389 pCreateInfos[i].basePipelineIndex, createInfoCount);
6390 }
6391 } else {
6392 if (pCreateInfos[i].basePipelineIndex != -1) {
6393 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006394 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006395 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6396 }
6397 }
6398 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006399 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6400 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6401 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6402 "vkCreateRayTracingPipelinesKHR: If flags includes "
6403 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6404 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006405 }
6406 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6407 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6408 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6409 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6410 "pLibraryInfo and pLibraryInterface must be NULL.");
6411 }
6412 if (pCreateInfos[i].pLibraryInfo) {
6413 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6414 if (pCreateInfos[i].stageCount == 0) {
6415 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6416 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6417 "stageCount must not be 0.");
6418 }
6419 if (pCreateInfos[i].groupCount == 0) {
6420 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6421 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6422 "groupCount must not be 0.");
6423 }
6424 } else {
6425 if (pCreateInfos[i].pLibraryInterface == NULL) {
6426 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6427 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6428 "is greater than 0, its "
6429 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006430 }
6431 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006432 }
6433 if (pCreateInfos[i].pLibraryInterface) {
6434 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6435 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6436 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6437 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6438 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6439 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006440 }
6441 if (deferredOperation != VK_NULL_HANDLE) {
6442 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6443 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6444 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6445 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006446 }
6447 }
ziga-lunargdea76582021-09-17 14:38:08 +02006448 if (pCreateInfos[i].pDynamicState) {
6449 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6450 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6451 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6452 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6453 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6454 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6455 }
6456 }
6457 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006458 }
6459
6460 return skip;
6461}
6462
Mike Schuchardt21638df2019-03-16 10:52:02 -07006463#ifdef VK_USE_PLATFORM_WIN32_KHR
6464bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6465 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006466 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006467 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006468 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006469 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006470 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006471 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006472 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006473 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006474 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006475 skip |=
6476 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006477 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006478 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6479 skip |= validate_struct_type(
6480 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6481 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6482 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6483 if (pSurfaceInfo != NULL) {
6484 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6485 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6486 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6487
6488 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6489 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6490 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6491 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006492 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6493 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006494
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006495 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6496 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6497 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6498 "VK_GOOGLE_surfaceless_query is not enabled.");
6499 }
6500
Mike Schuchardt21638df2019-03-16 10:52:02 -07006501 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6502 }
6503 return skip;
6504}
6505#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006506
6507bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6508 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006509 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006510 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6511 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006512 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006513 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6514 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6515 }
6516 return skip;
6517}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006518
6519bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006520 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006521 bool skip = false;
6522
6523 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006524 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006525 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006526 }
6527
6528 return skip;
6529}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006530
6531bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006532 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006533 bool skip = false;
6534
6535 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006536 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6537 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006538 }
6539
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006540 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006541 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006542 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6543 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006544 }
6545
6546 return skip;
6547}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006548
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006549bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6550 uint32_t bindingCount, const VkBuffer *pBuffers,
6551 const VkDeviceSize *pOffsets) const {
6552 bool skip = false;
6553 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006554 skip |=
6555 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6556 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6557 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006558 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6559 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006560 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6561 ") must be less than "
6562 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006563 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6564 }
6565
Jeff Bolz165818a2020-05-08 11:19:03 -05006566 for (uint32_t i = 0; i < bindingCount; ++i) {
6567 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006568 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006569 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006570 skip |=
6571 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6572 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006573 } else {
6574 if (pOffsets[i] != 0) {
6575 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006576 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6577 "] is not 0",
6578 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006579 }
6580 }
6581 }
6582 }
6583
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006584 return skip;
6585}
6586
Mark Lobodzinski84988402019-09-11 15:27:30 -06006587bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006588 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006589 bool skip = false;
6590 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006591 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6592 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006593 }
6594 return skip;
6595}
6596
6597bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006598 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006599 bool skip = false;
6600 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006601 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6602 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006603 }
6604 return skip;
6605}
Petr Kraus3d720392019-11-13 02:52:39 +01006606
6607bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6608 VkSemaphore semaphore, VkFence fence,
6609 uint32_t *pImageIndex) const {
6610 bool skip = false;
6611
6612 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006613 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6614 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006615 }
6616
6617 return skip;
6618}
6619
6620bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6621 uint32_t *pImageIndex) const {
6622 bool skip = false;
6623
6624 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006625 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6626 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006627 }
6628
6629 return skip;
6630}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006631
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006632bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6633 uint32_t firstBinding, uint32_t bindingCount,
6634 const VkBuffer *pBuffers,
6635 const VkDeviceSize *pOffsets,
6636 const VkDeviceSize *pSizes) const {
6637 bool skip = false;
6638
6639 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6640 for (uint32_t i = 0; i < bindingCount; ++i) {
6641 if (pOffsets[i] & 3) {
6642 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6643 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6644 }
6645 }
6646
6647 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6648 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6649 "%s: The firstBinding(%" PRIu32
6650 ") index is greater than or equal to "
6651 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6652 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6653 }
6654
6655 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6656 skip |=
6657 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6658 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6659 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6660 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6661 }
6662
6663 for (uint32_t i = 0; i < bindingCount; ++i) {
6664 // pSizes is optional and may be nullptr.
6665 if (pSizes != nullptr) {
6666 if (pSizes[i] != VK_WHOLE_SIZE &&
6667 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6668 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6669 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6670 ") is not VK_WHOLE_SIZE and is greater than "
6671 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6672 cmd_name, i, pSizes[i]);
6673 }
6674 }
6675 }
6676
6677 return skip;
6678}
6679
6680bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6681 uint32_t firstCounterBuffer,
6682 uint32_t counterBufferCount,
6683 const VkBuffer *pCounterBuffers,
6684 const VkDeviceSize *pCounterBufferOffsets) const {
6685 bool skip = false;
6686
6687 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6688 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6689 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6690 "%s: The firstCounterBuffer(%" PRIu32
6691 ") index is greater than or equal to "
6692 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6693 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6694 }
6695
6696 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6697 skip |=
6698 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6699 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6700 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6701 cmd_name, firstCounterBuffer, counterBufferCount,
6702 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6703 }
6704
6705 return skip;
6706}
6707
6708bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6709 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6710 const VkBuffer *pCounterBuffers,
6711 const VkDeviceSize *pCounterBufferOffsets) const {
6712 bool skip = false;
6713
6714 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6715 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6716 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6717 "%s: The firstCounterBuffer(%" PRIu32
6718 ") index is greater than or equal to "
6719 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6720 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6721 }
6722
6723 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6724 skip |=
6725 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6726 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6727 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6728 cmd_name, firstCounterBuffer, counterBufferCount,
6729 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6730 }
6731
6732 return skip;
6733}
6734
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006735bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6736 uint32_t firstInstance, VkBuffer counterBuffer,
6737 VkDeviceSize counterBufferOffset,
6738 uint32_t counterOffset, uint32_t vertexStride) const {
6739 bool skip = false;
6740
6741 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006742 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6743 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6744 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6745 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006746 }
6747
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006748 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006749 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006750 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006751 }
6752
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006753 return skip;
6754}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006755
6756bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6757 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6758 const VkAllocationCallbacks *pAllocator,
6759 VkSamplerYcbcrConversion *pYcbcrConversion,
6760 const char *apiName) const {
6761 bool skip = false;
6762
6763 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006764 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006765 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006766 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006767 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6768 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006769 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006770 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006771 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006772
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006773#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006774 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006775 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006776#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006777 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006778#endif
6779
sfricke-samsung1a72f942020-07-25 12:09:18 -07006780 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006781
6782 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006783 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006784 const VkComponentMapping components = pCreateInfo->components;
6785 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6786 if (FormatIsXChromaSubsampled(format) == true) {
6787 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6788 skip |=
6789 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006790 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6791 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006792 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006793 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006794
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006795 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6796 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6797 skip |= LogError(
6798 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6799 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6800 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6801 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6802 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006803
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006804 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6805 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6806 skip |=
6807 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006808 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6809 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006810 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006811 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006812
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006813 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6814 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6815 skip |=
6816 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006817 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6818 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006819 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006820 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006821
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006822 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006823 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6824 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6825 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006826 skip |=
6827 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006828 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6829 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006830 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6831 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006832 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006833 }
6834
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006835 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6836 // Checks same VU multiple ways in order to give a more useful error message
6837 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6838 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6839 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6840 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6841 skip |= LogError(
6842 device, vuid,
6843 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6844 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6845 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6846 string_VkComponentSwizzle(components.b));
6847 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006848
sfricke-samsunged028b02021-09-06 23:14:51 -07006849 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6850 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006851 // 3 = no [a]
6852 // 2 = no [b,a]
6853 // 1 = no [g,b,a]
6854 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006855 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006856
sfricke-samsunged028b02021-09-06 23:14:51 -07006857 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6858 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006859 skip |= LogError(device, vuid,
6860 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6861 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6862 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6863 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006864 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006865 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6866 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6867 skip |= LogError(device, vuid,
6868 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6869 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6870 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6871 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6872 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006873 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006874 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6875 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6876 skip |= LogError(device, vuid,
6877 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6878 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6879 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6880 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6881 string_VkComponentSwizzle(components.b));
6882 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006883 }
6884 }
6885
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006886 return skip;
6887}
6888
6889bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6890 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6891 const VkAllocationCallbacks *pAllocator,
6892 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6893 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6894 "vkCreateSamplerYcbcrConversion");
6895}
6896
6897bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6898 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6899 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6900 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6901 "vkCreateSamplerYcbcrConversionKHR");
6902}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006903
6904bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6905 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6906 bool skip = false;
6907 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6908 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6909
6910 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006911 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6912 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6913 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6914 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6915 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006916 }
6917 return skip;
6918}
sourav parmara96ab1a2020-04-25 16:28:23 -07006919
6920bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006921 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006922 bool skip = false;
6923 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6924 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6925 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6926 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006927 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006928 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6929 skip |= LogError(
6930 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6931 "vkCopyAccelerationStructureToMemoryKHR: The "
6932 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6933 }
6934 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6935 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6936 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6937 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6938 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6939 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006940 return skip;
6941}
6942
6943bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6944 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6945 bool skip = false;
6946 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6947 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6948 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6949 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6950 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006951 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6952 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006953 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006954 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006955 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006956 return skip;
6957}
6958
6959bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6960 const char *api_name) const {
6961 bool skip = false;
6962 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6963 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6964 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6965 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6966 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6967 api_name);
6968 }
6969 return skip;
6970}
6971
6972bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006973 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006974 bool skip = false;
6975 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006976 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006977 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006978 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006979 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6980 "vkCopyAccelerationStructureKHR: The "
6981 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006982 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006983 return skip;
6984}
6985
6986bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6987 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6988 bool skip = false;
6989 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6990 return skip;
6991}
6992
6993bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006994 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006995 bool skip = false;
6996 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006997 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006998 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6999 }
7000 return skip;
7001}
7002
7003bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007004 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007005 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007006 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007007 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007008 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7009 skip |= LogError(
7010 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
7011 "vkCopyMemoryToAccelerationStructureKHR: The "
7012 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007013 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007014 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
7015 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07007016 return skip;
7017}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06007018
sourav parmara96ab1a2020-04-25 16:28:23 -07007019bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
7020 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
7021 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007022 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07007023 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
7024 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007025 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007026 pInfo->src.deviceAddress);
7027 }
sourav parmar83c31b12020-05-06 12:30:54 -07007028 return skip;
7029}
7030bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7031 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7032 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7033 bool skip = false;
7034 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7035 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007036 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7037 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7038 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7039 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7040 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7041 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7042 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7043 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7044 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7045 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7046 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7047 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7048 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7049 }
sourav parmar83c31b12020-05-06 12:30:54 -07007050 }
7051 return skip;
7052}
7053bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7054 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7055 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7056 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007057 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007058 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7059 skip |= LogError(
7060 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7061 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7062 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7063 }
sourav parmar83c31b12020-05-06 12:30:54 -07007064 if (dataSize < accelerationStructureCount * stride) {
7065 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7066 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007067 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007068 dataSize, accelerationStructureCount, stride);
7069 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007070
sourav parmar83c31b12020-05-06 12:30:54 -07007071 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7072 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007073 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7074 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7075 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7076 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7077 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7078 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7079 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7080 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7081 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7082 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7083 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7084 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7085 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7086 }
sourav parmar83c31b12020-05-06 12:30:54 -07007087 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007088
7089 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7090 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007091 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7092 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7093 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7094 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7095 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007096 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007097 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7098 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7099 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7100 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7101 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007102 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7103 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7104 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7105 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7106 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7107 stride);
7108 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7109 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7110 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7111 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7112 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7113 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007114 }
7115 }
sourav parmar83c31b12020-05-06 12:30:54 -07007116 return skip;
7117}
7118bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7119 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7120 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007121 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007122 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7123 skip |= LogError(
7124 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7125 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7126 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007127 }
7128 return skip;
7129}
7130
7131bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007132 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7133 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7134 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7135 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007136 uint32_t width, uint32_t height, uint32_t depth) const {
7137 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007138 // RayGen
7139 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7140 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7141 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007142 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007143 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7144 0) {
7145 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7146 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7147 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7148 }
7149 // Callable
7150 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7151 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7152 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7153 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007154 }
7155 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7156 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7157 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007158 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7159 }
7160 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7161 0) {
7162 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7163 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7164 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007165 }
7166 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007167 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7168 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7169 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7170 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007171 }
7172 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7173 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007174 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7175 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007176 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007177 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7178 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7179 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7180 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7181 }
sourav parmar83c31b12020-05-06 12:30:54 -07007182 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007183 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7184 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7185 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7186 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007187 }
7188 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7189 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7190 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007191 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7192 }
7193 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7194 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7195 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7196 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7197 }
7198 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007199 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007200 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7201 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7202 }
7203 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7204 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007205 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007206 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7207 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007208 }
7209
sourav parmarcd5fb182020-07-17 12:58:44 -07007210 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7211 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007212 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007213 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7214 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7215 }
7216
7217 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7218 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007219 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007220 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7221 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007222 }
7223 return skip;
7224}
7225
sourav parmarcd5fb182020-07-17 12:58:44 -07007226bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7227 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7228 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7229 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007230 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007231 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007232 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7233 skip |= LogError(
7234 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7235 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7236 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007237 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007238 // RayGen
7239 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7240 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7241 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007242 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007243 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7244 0) {
7245 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7246 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7247 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7248 }
7249 // Callabe
7250 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7251 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7252 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7253 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007254 }
7255 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7256 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007257 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7258 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7259 }
7260 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7261 0) {
7262 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7263 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7264 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007265 }
7266 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007267 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7268 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7269 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7270 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007271 }
7272 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7273 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007274 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7275 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007276 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007277 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7278 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7279 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7280 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7281 }
sourav parmar83c31b12020-05-06 12:30:54 -07007282 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007283 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7284 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7285 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7286 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007287 }
7288 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7289 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007290 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7291 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7292 }
7293 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7294 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7295 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7296 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007297 }
7298
sourav parmarcd5fb182020-07-17 12:58:44 -07007299 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7300 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7301 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007302 }
7303 return skip;
7304}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007305
7306bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7307 VkDeviceAddress indirectDeviceAddress) const {
7308 bool skip = false;
7309 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7310 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7311 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007312 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007313 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7314 "feature must be enabled.");
7315 }
7316
7317 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7318 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7319 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7320 }
7321 return skip;
7322}
7323
sourav parmar83c31b12020-05-06 12:30:54 -07007324bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7325 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7326 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7327 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7328 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7329 uint32_t width, uint32_t height, uint32_t depth) const {
7330 bool skip = false;
7331 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7332 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7333 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7334 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7335 }
7336 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7337 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7338 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7339 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7340 }
7341 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7342 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7343 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7344 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7345 }
7346
7347 // hitShader
7348 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7349 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7350 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7351 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7352 }
7353 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7354 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7355 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7356 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7357 }
7358 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7359 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7360 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7361 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7362 }
7363
7364 // missShader
7365 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7366 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7367 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7368 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7369 }
7370 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7371 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7372 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7373 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7374 }
7375 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7376 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7377 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7378 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7379 }
7380
7381 // raygenShader
7382 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7383 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7384 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007385 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7386 }
7387 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7388 skip |=
7389 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7390 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7391 }
7392 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7393 skip |=
7394 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7395 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7396 }
7397 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7398 skip |=
7399 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7400 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007401 }
7402 return skip;
7403}
7404
sourav parmar83c31b12020-05-06 12:30:54 -07007405bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007406 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7407 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007408 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007409 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7410 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007411 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7412 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007413 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007414 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7415 }
7416 return skip;
7417}
7418
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007419bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7420 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007421 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007422 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007423
7424 if (!physical_device_features.multiViewport) {
7425 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007426 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7427 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007428 viewportCount);
7429 }
7430 } else { // multiViewport enabled
7431 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007432 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7433 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007434 ") must "
7435 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007436 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007437 }
7438 }
7439
7440 if (pViewports) {
7441 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7442 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007443 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007444 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007445 }
7446 }
7447
7448 return skip;
7449}
7450
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007451bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7452 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007453 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007454 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7455 return skip;
7456}
7457
7458bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7459 const VkViewport *pViewports) const {
7460 bool skip = false;
7461 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7462 return skip;
7463}
7464
7465bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7466 const VkRect2D *pScissors, bool is_ext) const {
7467 bool skip = false;
7468 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007469
7470 if (!physical_device_features.multiViewport) {
7471 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007472 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7473 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007474 ") must "
7475 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007476 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007477 }
7478 } else { // multiViewport enabled
7479 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007480 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7481 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007482 ") must "
7483 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007484 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007485 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007486 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7487 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007488 ") must "
7489 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007490 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007491 }
7492 }
7493
7494 if (pScissors) {
7495 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7496 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7497
7498 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007499 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7500 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007501 }
7502
7503 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007504 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7505 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007506 }
7507
7508 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7509 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007510 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7511 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7512 "] will overflow int32_t.",
7513 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007514 }
7515
7516 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7517 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007518 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7519 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7520 "] will overflow int32_t.",
7521 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7522 }
7523 }
7524 }
7525
7526 return skip;
7527}
7528
7529bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7530 const VkRect2D *pScissors) const {
7531 bool skip = false;
7532 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7533 return skip;
7534}
7535
7536bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7537 const VkRect2D *pScissors) const {
7538 bool skip = false;
7539 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7540 return skip;
7541}
7542
7543bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7544 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7545 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7546 bool is_2ext) const {
7547 bool skip = false;
7548 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7549 if (firstBinding >= device_limits.maxVertexInputBindings) {
7550 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7551 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7552 firstBinding, device_limits.maxVertexInputBindings);
7553 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7554 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7555 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7556 ") must be less than "
7557 "maxVertexInputBindings (%" PRIu32 ")",
7558 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7559 }
7560
7561 for (uint32_t i = 0; i < bindingCount; ++i) {
7562 if (pBuffers[i] == VK_NULL_HANDLE) {
7563 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7564 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7565 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7566 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7567 } else {
7568 if (pOffsets[i] != 0) {
7569 skip |=
7570 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7571 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7572 }
7573 }
7574 }
7575 if (pStrides) {
7576 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7577 skip |=
7578 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7579 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7580 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007581 }
7582 }
7583 }
7584
7585 return skip;
7586}
7587
7588bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7589 uint32_t bindingCount, const VkBuffer *pBuffers,
7590 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7591 const VkDeviceSize *pStrides) const {
7592 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007593 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7594 return skip;
7595}
Piers Daniell39842ee2020-07-10 16:42:33 -06007596
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007597bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7598 uint32_t bindingCount, const VkBuffer *pBuffers,
7599 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7600 const VkDeviceSize *pStrides) const {
7601 bool skip = false;
7602 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007603 return skip;
7604}
sourav parmarcd5fb182020-07-17 12:58:44 -07007605
7606bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7607 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7608 bool skip = false;
7609 for (uint32_t i = 0; i < infoCount; ++i) {
7610 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7611 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7612 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7613 }
7614 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7615 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7616 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7617 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7618 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7619 api_name);
7620 }
7621 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7622 skip |=
7623 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7624 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7625 }
7626 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7627 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7628 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7629 }
7630 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7631 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7632 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7633 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7634 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7635 api_name);
7636 }
7637 if (pInfos[i].pGeometries) {
7638 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7639 skip |= validate_ranged_enum(
7640 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7641 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7642 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7643 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007644 skip |= validate_struct_type(
7645 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7646 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7647 &(pInfos[i].pGeometries[j].geometry.triangles),
7648 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7649 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7650 skip |= validate_struct_pnext(
7651 api_name,
7652 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7653 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7654 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7655 skip |=
7656 validate_ranged_enum(api_name,
7657 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7658 ParameterName::IndexVector{i, j}),
7659 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7660 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7661 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7662 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7663 &pInfos[i].pGeometries[j].geometry.triangles,
7664 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7665 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7666 skip |= validate_ranged_enum(
7667 api_name,
7668 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7669 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7670 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7671
7672 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7673 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7674 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7675 }
7676 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7677 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7678 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7679 skip |=
7680 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7681 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7682 api_name);
7683 }
7684 }
7685 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7686 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7687 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7688 &pInfos[i].pGeometries[j].geometry.instances,
7689 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7690 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7691 skip |= validate_struct_type(
7692 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7693 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7694 &(pInfos[i].pGeometries[j].geometry.instances),
7695 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7696 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7697 skip |= validate_struct_pnext(
7698 api_name,
7699 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7700 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7701 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7702
7703 skip |= validate_bool32(api_name,
7704 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7705 ParameterName::IndexVector{i, j}),
7706 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7707 }
7708 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7709 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7710 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7711 &pInfos[i].pGeometries[j].geometry.aabbs,
7712 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7713 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7714 skip |= validate_struct_type(
7715 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7716 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7717 &(pInfos[i].pGeometries[j].geometry.aabbs),
7718 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7719 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7720 skip |= validate_struct_pnext(
7721 api_name,
7722 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7723 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7724 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7725 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7726 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7727 "(%s):stride must be less than or equal to 2^32-1", api_name);
7728 }
7729 }
7730 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7731 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7732 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7733 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7734 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7735 api_name);
7736 }
7737 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7738 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7739 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7740 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7741 "of elements of"
7742 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7743 api_name);
7744 }
7745 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7746 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7747 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7748 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7749 api_name);
7750 }
7751 }
7752 }
7753 }
7754 if (pInfos[i].ppGeometries != NULL) {
7755 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7756 skip |= validate_ranged_enum(
7757 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7758 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7759 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7760 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007761 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7762 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7763 &pInfos[i].ppGeometries[j]->geometry.triangles,
7764 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7765 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7766 skip |= validate_struct_type(
7767 api_name,
7768 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7769 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7770 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7771 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7772 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7773 skip |= validate_struct_pnext(
7774 api_name,
7775 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7776 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7777 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7778 skip |= validate_ranged_enum(api_name,
7779 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7780 ParameterName::IndexVector{i, j}),
7781 "VkFormat", AllVkFormatEnums,
7782 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7783 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7784 skip |= validate_ranged_enum(api_name,
7785 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7786 ParameterName::IndexVector{i, j}),
7787 "VkIndexType", AllVkIndexTypeEnums,
7788 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7789 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7790 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7791 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7792 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7793 }
7794 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7795 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7796 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7797 skip |=
7798 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7799 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7800 api_name);
7801 }
7802 }
7803 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7804 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7805 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7806 &pInfos[i].ppGeometries[j]->geometry.instances,
7807 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7808 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7809 skip |= validate_struct_type(
7810 api_name,
7811 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7812 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7813 &(pInfos[i].ppGeometries[j]->geometry.instances),
7814 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7815 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7816 skip |= validate_struct_pnext(
7817 api_name,
7818 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7819 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7820 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7821 skip |= validate_bool32(api_name,
7822 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7823 ParameterName::IndexVector{i, j}),
7824 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7825 }
7826 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7827 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7828 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7829 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7830 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7831 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7832 skip |= validate_struct_type(
7833 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7834 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7835 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7836 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7837 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7838 skip |= validate_struct_pnext(
7839 api_name,
7840 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7841 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7842 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7843 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7844 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7845 "(%s):stride must be less than or equal to 2^32-1", api_name);
7846 }
7847 }
7848 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7849 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7850 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7851 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7852 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7853 api_name);
7854 }
7855 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7856 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7857 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7858 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7859 "of elements of"
7860 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7861 api_name);
7862 }
7863 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7864 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7865 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7866 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7867 api_name);
7868 }
7869 }
7870 }
7871 }
7872 }
7873 return skip;
7874}
7875bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7876 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7877 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7878 bool skip = false;
7879 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7880 for (uint32_t i = 0; i < infoCount; ++i) {
7881 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7882 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7883 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7884 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7885 "scratchData.deviceAddress member must be a multiple of "
7886 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7887 }
7888 for (uint32_t k = 0; k < infoCount; ++k) {
7889 if (i == k) continue;
7890 bool found = false;
7891 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007892 skip |=
7893 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7894 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7895 ") of pInfos must "
7896 "not be "
7897 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7898 ") of pInfos.",
7899 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007900 found = true;
7901 }
7902 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007903 skip |=
7904 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7905 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7906 ") of pInfos must "
7907 "not be "
7908 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7909 ") of pInfos.",
7910 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007911 found = true;
7912 }
7913 if (found) break;
7914 }
7915 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7916 if (pInfos[i].pGeometries) {
7917 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7918 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7919 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7920 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7921 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7922 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7923 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7924 }
7925 } else {
7926 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7927 skip |=
7928 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7929 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7930 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7931 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7932 }
7933 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007934 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007935 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7936 skip |= LogError(
7937 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7938 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7939 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7940 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007941 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7942 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007943 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7944 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7945 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7946 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7947 }
7948 }
7949 } else if (pInfos[i].ppGeometries) {
7950 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7951 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7952 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7953 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7954 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7955 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7956 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7957 }
7958 } else {
7959 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7960 skip |=
7961 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7962 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7963 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7964 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7965 }
7966 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007967 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007968 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7969 skip |= LogError(
7970 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7971 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7972 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7973 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007974 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7975 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007976 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7977 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7978 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7979 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7980 }
7981 }
7982 }
7983 }
7984 }
7985 return skip;
7986}
7987
7988bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7989 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7990 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7991 const uint32_t *const *ppMaxPrimitiveCounts) const {
7992 bool skip = false;
7993 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7994 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007995 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007996 if (!ray_tracing_acceleration_structure_features ||
7997 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7998 skip |= LogError(
7999 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
8000 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
8001 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
8002 }
8003 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008004 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8005 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8006 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
8007 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
8008 "scratchData.deviceAddress member must be a multiple of "
8009 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8010 }
8011 for (uint32_t k = 0; k < infoCount; ++k) {
8012 if (i == k) continue;
8013 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008014 skip |= LogError(
8015 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
8016 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
8017 ") "
8018 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
8019 "any other element [%" PRIu32 ") of pInfos.",
8020 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008021 break;
8022 }
8023 }
8024 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8025 if (pInfos[i].pGeometries) {
8026 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8027 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8028 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8029 skip |= LogError(
8030 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8031 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8032 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8033 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8034 }
8035 } else {
8036 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8037 skip |= LogError(
8038 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8039 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8040 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8041 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8042 }
8043 }
8044 }
8045 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8046 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8047 skip |= LogError(
8048 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8049 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8050 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8051 }
8052 }
8053 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8054 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8055 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8056 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8057 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8058 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8059 }
8060 }
8061 } else if (pInfos[i].ppGeometries) {
8062 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8063 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8064 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8065 skip |= LogError(
8066 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8067 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8068 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8069 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8070 }
8071 } else {
8072 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8073 skip |= LogError(
8074 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8075 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8076 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8077 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8078 }
8079 }
8080 }
8081 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8082 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8083 skip |= LogError(
8084 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8085 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8086 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8087 }
8088 }
8089 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8090 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8091 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8092 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8093 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8094 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8095 }
8096 }
8097 }
8098 }
8099 }
8100 return skip;
8101}
8102
8103bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8104 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8105 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8106 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8107 bool skip = false;
8108 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8109 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008110 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008111 if (!ray_tracing_acceleration_structure_features ||
8112 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8113 skip |=
8114 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8115 "vkBuildAccelerationStructuresKHR: The "
8116 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8117 }
8118 for (uint32_t i = 0; i < infoCount; ++i) {
8119 for (uint32_t j = 0; j < infoCount; ++j) {
8120 if (i == j) continue;
8121 bool found = false;
8122 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008123 skip |=
8124 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8125 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8126 ") of pInfos must "
8127 "not be "
8128 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8129 ") of pInfos.",
8130 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008131 found = true;
8132 }
8133 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008134 skip |=
8135 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8136 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8137 ") of pInfos must "
8138 "not be "
8139 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8140 ") of pInfos.",
8141 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008142 found = true;
8143 }
8144 if (found) break;
8145 }
8146 }
8147 return skip;
8148}
8149
8150bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8151 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8152 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8153 bool skip = false;
8154 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8155 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008156 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8157 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008158 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8159 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008160 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008161 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8162 }
8163 if (pBuildInfo != nullptr) {
8164 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8165 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8166 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8167 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8168 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008169 }
8170 return skip;
8171}
sfricke-samsungecafb192021-01-17 08:21:14 -08008172
Piers Daniellcb6d8032021-04-19 18:51:26 -06008173bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8174 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8175 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8176 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8177 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008178 const auto *vertex_attribute_divisor_features =
8179 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8180
Piers Daniellcb6d8032021-04-19 18:51:26 -06008181 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8182 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8183 skip |=
8184 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8185 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8186 }
8187
8188 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8189 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8190 skip |= LogError(
8191 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8192 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8193 }
8194
8195 // VUID-vkCmdSetVertexInputEXT-binding-04793
8196 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8197 bool binding_found = false;
8198 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8199 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8200 binding_found = true;
8201 break;
8202 }
8203 }
8204 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008205 skip |= LogError(
8206 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8207 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008208 }
8209 }
8210
8211 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8212 if (vertexBindingDescriptionCount > 1) {
8213 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8214 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8215 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8216 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8217 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008218 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8219 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008220 }
8221 }
8222 }
8223 }
8224
8225 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8226 if (vertexAttributeDescriptionCount > 1) {
8227 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8228 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8229 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8230 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8231 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008232 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8233 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008234 }
8235 }
8236 }
8237 }
8238
8239 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8240 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8241 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008242 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8243 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8244 "].binding is greater than maxVertexInputBindings",
8245 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008246 }
8247
8248 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8249 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008250 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8251 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8252 "].stride is greater than maxVertexInputBindingStride",
8253 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008254 }
8255
8256 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8257 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8258 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8259 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008260 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8261 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008262 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8263 binding);
8264 }
8265
8266 if (pVertexBindingDescriptions[binding].divisor > 1) {
8267 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8268 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8269 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008270 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8271 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008272 "vertexAttributeInstanceRateDivisor is not enabled",
8273 binding);
8274 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008275 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008276 if (pVertexBindingDescriptions[binding].divisor >
8277 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008278 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8279 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8280 "].divisor is greater than maxVertexAttribDivisor",
8281 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008282 }
8283
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008284 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008285 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008286 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8287 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8288 "].divisor is greater than 1 but inputRate "
8289 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8290 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008291 }
8292 }
8293 }
8294 }
8295
8296 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008297 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008298 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008299 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8300 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8301 "].location is greater than maxVertexInputAttributes",
8302 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008303 }
8304
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008305 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008306 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008307 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8308 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8309 "].binding is greater than maxVertexInputBindings",
8310 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008311 }
8312
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008313 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008314 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008315 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8316 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8317 "].offset is greater than maxVertexInputAttributeOffset",
8318 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008319 }
8320
8321 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8322 VkFormatProperties properties;
8323 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8324 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8325 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008326 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8327 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008328 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8329 attribute);
8330 }
8331 }
8332
8333 return skip;
8334}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008335
8336bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8337 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8338 const void *pValues) const {
8339 bool skip = false;
8340 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8341 // Check that offset + size don't exceed the max.
8342 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8343 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008344 skip |=
8345 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8346 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8347 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008348 }
8349 if (size > max_push_constants_size - offset) {
8350 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008351 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8352 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008353 offset, size, max_push_constants_size);
8354 }
8355
8356 // size needs to be non-zero and a multiple of 4.
8357 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008358 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8359 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008360 }
8361
8362 // offset needs to be a multiple of 4.
8363 if ((offset & 0x3) != 0) {
8364 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008365 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008366 }
8367 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008368}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008369
8370bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8371 uint32_t srcCacheCount,
8372 const VkPipelineCache *pSrcCaches) const {
8373 bool skip = false;
8374 if (pSrcCaches) {
8375 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8376 if (pSrcCaches[index0] == dstCache) {
8377 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8378 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8379 report_data->FormatHandle(dstCache).c_str());
8380 break;
8381 }
8382 }
8383 }
8384 return skip;
8385}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008386
8387bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8388 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8389 uint32_t rangeCount,
8390 const VkImageSubresourceRange *pRanges) const {
8391 bool skip = false;
8392 if (!pColor) {
8393 skip |=
8394 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8395 }
8396 return skip;
8397}
8398
8399bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8400 const VkRenderPassBeginInfo *const rp_begin) const {
8401 bool skip = false;
8402 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8403 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8404 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008405 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008406 func_name, rp_begin->clearValueCount);
8407 }
8408 return skip;
8409}
8410
8411bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8412 VkSubpassContents) const {
8413 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8414 return skip;
8415}
8416
8417bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8418 const VkRenderPassBeginInfo *pRenderPassBegin,
8419 const VkSubpassBeginInfo *) const {
8420 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8421 return skip;
8422}
8423
8424bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8425 const VkSubpassBeginInfo *) const {
8426 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8427 return skip;
8428}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008429
8430bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8431 uint32_t firstDiscardRectangle,
8432 uint32_t discardRectangleCount,
8433 const VkRect2D *pDiscardRectangles) const {
8434 bool skip = false;
8435
8436 if (pDiscardRectangles) {
8437 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8438 const int64_t x_sum =
8439 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8440 if (x_sum > std::numeric_limits<int32_t>::max()) {
8441 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8442 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8443 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8444 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8445 }
8446
8447 const int64_t y_sum =
8448 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8449 if (y_sum > std::numeric_limits<int32_t>::max()) {
8450 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8451 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8452 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8453 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8454 }
8455 }
8456 }
8457
8458 return skip;
8459}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008460
8461bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8462 uint32_t queryCount, size_t dataSize, void *pData,
8463 VkDeviceSize stride, VkQueryResultFlags flags) const {
8464 bool skip = false;
8465
8466 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8467 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8468 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8469 }
8470
8471 return skip;
8472}
ziga-lunargcf340c42021-08-19 00:13:38 +02008473
8474bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8475 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8476 bool skip = false;
8477
8478 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8479 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8480 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8481 ") is not a multiple of 4.",
8482 pConditionalRenderingBegin->offset);
8483 }
8484
8485 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008486}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008487
8488bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8489 VkSurfaceKHR surface,
8490 uint32_t *pSurfaceFormatCount,
8491 VkSurfaceFormatKHR *pSurfaceFormats) const {
8492 bool skip = false;
8493 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8494 skip |= LogError(
8495 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8496 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8497 }
8498 return skip;
8499}
8500
8501bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8502 VkSurfaceKHR surface,
8503 uint32_t *pPresentModeCount,
8504 VkPresentModeKHR *pPresentModes) const {
8505 bool skip = false;
8506 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8507 skip |= LogError(
8508 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8509 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8510 }
8511 return skip;
8512}
8513
8514bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8515 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8516 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8517 bool skip = false;
8518 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8519 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8520 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8521 "VK_GOOGLE_surfaceless_query is not enabled.");
8522 }
8523 return skip;
8524}
8525
8526bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8527 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8528 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8529 bool skip = false;
8530 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8531 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8532 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8533 "VK_GOOGLE_surfaceless_query is not enabled.");
8534 }
8535 return skip;
8536}
8537
8538#ifdef VK_USE_PLATFORM_WIN32_KHR
8539bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8540 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8541 VkPresentModeKHR *pPresentModes) const {
8542 bool skip = false;
8543 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8544 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8545 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8546 "VK_GOOGLE_surfaceless_query is not enabled.");
8547 }
8548 return skip;
8549}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008550
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008551#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008552
8553bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8554 const char *func_name) const {
8555 bool skip = false;
8556
8557 if (pInfo && pInfo->pCreateInfo) {
8558 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8559 if (image_swapchain_create_info) {
8560 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8561 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8562 }
8563 }
8564
8565 return skip;
8566}
8567
8568bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8569 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8570 bool skip = false;
8571
8572 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8573
8574 return skip;
8575}
8576
8577bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8578 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8579 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8580 bool skip = false;
8581
8582 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8583
8584 return skip;
8585}