blob: 70a380cd5768485518791c74306e396ca3565f0e [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 Cesario73c994c2022-05-26 23:07:34 -06001635 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001636 for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
1637 if (!pCreateInfo->pSetLayouts[i]) {
Nathaniel Cesario73c994c2022-05-26 23:07:34 -06001638 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561",
1639 "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32
1640 "] is VK_NULL_HANDLE, but VK_EXT_graphics_pipeline_library is not enabled.",
1641 i);
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001642 }
1643 }
1644 }
1645
sfricke-samsung51303fb2021-05-09 19:09:13 -07001646 // Validate Push Constant ranges
1647 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1648 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1649 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1650 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1651 // Check that offset + size don't exceed the max.
1652 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1653 if (offset >= max_push_constants_size) {
1654 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001655 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1656 ") that exceeds this "
1657 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001658 i, offset, max_push_constants_size);
1659 }
1660 if (size > max_push_constants_size - offset) {
1661 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001662 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1663 ") and size (%" PRIu32
1664 ") "
1665 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001666 i, offset, size, max_push_constants_size);
1667 }
1668
1669 // size needs to be non-zero and a multiple of 4.
1670 if (size == 0) {
1671 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001672 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1673 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001674 i, size);
1675 }
1676 if (size & 0x3) {
1677 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001678 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1679 ") is not a multiple of 4.",
1680 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001681 }
1682
1683 // offset needs to be a multiple of 4.
1684 if ((offset & 0x3) != 0) {
1685 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001686 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1687 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001688 i, offset);
1689 }
1690 }
1691
1692 // 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.
1693 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1694 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1695 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001696 skip |=
1697 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1698 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001699 }
1700 }
1701 }
1702 return skip;
1703}
1704
ziga-lunargc6341372021-07-28 12:57:42 +02001705bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1706 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1707 bool skip = false;
1708
1709 const auto *required_subgroup_size_features =
1710 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1711
1712 if (required_subgroup_size_features) {
1713 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1714 skip |= LogError(
1715 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1716 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1717 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1718 func_name, msg, pCreateInfo->flags);
1719 }
1720 }
1721
1722 return skip;
1723}
1724
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001725bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1726 uint32_t createInfoCount,
1727 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1728 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001729 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001730 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001731
1732 if (pCreateInfos != nullptr) {
1733 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001734 bool has_dynamic_viewport = false;
1735 bool has_dynamic_scissor = false;
1736 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001737 bool has_dynamic_depth_bias = false;
1738 bool has_dynamic_blend_constant = false;
1739 bool has_dynamic_depth_bounds = false;
1740 bool has_dynamic_stencil_compare = false;
1741 bool has_dynamic_stencil_write = false;
1742 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001743 bool has_dynamic_viewport_w_scaling_nv = false;
1744 bool has_dynamic_discard_rectangle_ext = false;
1745 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001746 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001747 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001748 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001749 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001750 bool has_dynamic_cull_mode = false;
1751 bool has_dynamic_front_face = false;
1752 bool has_dynamic_primitive_topology = false;
1753 bool has_dynamic_viewport_with_count = false;
1754 bool has_dynamic_scissor_with_count = false;
1755 bool has_dynamic_vertex_input_binding_stride = false;
1756 bool has_dynamic_depth_test_enable = false;
1757 bool has_dynamic_depth_write_enable = false;
1758 bool has_dynamic_depth_compare_op = false;
1759 bool has_dynamic_depth_bounds_test_enable = false;
1760 bool has_dynamic_stencil_test_enable = false;
1761 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001762 bool has_patch_control_points = false;
1763 bool has_rasterizer_discard_enable = false;
1764 bool has_depth_bias_enable = false;
1765 bool has_logic_op = false;
1766 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001767 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001768
1769 // Create a copy of create_info and set non-included sub-state to null
1770 auto create_info = pCreateInfos[i];
1771 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1772 if (graphics_lib_info) {
Nathaniel Cesariobcb79682022-03-31 21:13:52 -06001773 // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries
1774 if (enabled[gpu_validation]) {
1775 skip |=
1776 LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported");
1777 }
1778 if (enabled[gpu_validation]) {
1779 skip |= LogError(device, kVUIDUndefined,
1780 "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported");
1781 }
1782
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001783 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1784 create_info.pVertexInputState = nullptr;
1785 create_info.pInputAssemblyState = nullptr;
1786 }
1787 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1788 create_info.pViewportState = nullptr;
1789 create_info.pRasterizationState = nullptr;
1790 create_info.pTessellationState = nullptr;
1791 }
1792 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1793 create_info.pDepthStencilState = nullptr;
1794 }
1795 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1796 create_info.pColorBlendState = nullptr;
1797 }
1798 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1799 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1800 create_info.pMultisampleState = nullptr;
1801 }
1802 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1803 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1804 create_info.layout = VK_NULL_HANDLE;
1805 }
1806 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1807 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1808 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1809 create_info.renderPass = VK_NULL_HANDLE;
1810 create_info.subpass = 0;
1811 }
1812 }
1813
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001814 if (!create_info.renderPass) {
1815 if (create_info.pColorBlendState && create_info.pMultisampleState) {
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001816 const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext);
ziga-lunarg97584c32022-04-22 14:33:37 +02001817 // Pipeline has fragment output state
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001818 if (rendering_struct) {
1819 if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1820 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1821 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1822 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001823
1824 if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) {
1825 skip |= LogError(
1826 device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587",
1827 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1828 "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.",
1829 i, string_VkFormat(rendering_struct->depthAttachmentFormat));
1830 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001831 }
1832
1833 if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1834 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1835 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1836 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001837 if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) {
Nathaniel Cesario1ba7ca52022-04-18 12:35:00 -06001838 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588",
1839 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1840 "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a "
1841 "stencil aspect.",
1842 i, string_VkFormat(rendering_struct->stencilAttachmentFormat));
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001843 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001844 }
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001845
1846 if (rendering_struct->colorAttachmentCount != 0) {
1847 skip |= validate_ranged_enum_array(
1848 "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579",
1849 "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums,
1850 rendering_struct->colorAttachmentCount, rendering_struct->pColorAttachmentFormats, true, true);
1851 }
ziga-lunarg97584c32022-04-22 14:33:37 +02001852
1853 if (rendering_struct->pColorAttachmentFormats) {
1854 for (uint32_t j = 0; j < rendering_struct->colorAttachmentCount; ++j) {
1855 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "pColorAttachmentFormats", "VkFormat",
1856 AllVkFormatEnums, rendering_struct->pColorAttachmentFormats[j],
1857 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06580");
1858 }
1859 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001860 }
ziga-lunarg47258542022-04-22 17:40:43 +02001861
1862 // VkAttachmentSampleCountInfoAMD == VkAttachmentSampleCountInfoNV
1863 auto attachment_sample_count_info = LvlFindInChain<VkAttachmentSampleCountInfoAMD>(create_info.pNext);
1864 if (attachment_sample_count_info && attachment_sample_count_info->pColorAttachmentSamples) {
1865 for (uint32_t j = 0; j < attachment_sample_count_info->colorAttachmentCount; ++j) {
1866 skip |= validate_flags("vkCreateGraphicsPipelines",
1867 ParameterName("VkAttachmentSampleCountInfoAMD->pColorAttachmentSamples"),
1868 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
1869 attachment_sample_count_info->pColorAttachmentSamples[j], kRequiredFlags,
1870 "VUID-VkGraphicsPipelineCreateInfo-pColorAttachmentSamples-06592");
1871 }
1872 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001873 }
1874 }
1875
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001876 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1877 if (create_info.stageCount == 0) {
1878 skip |=
1879 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1880 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1881 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1882 }
1883 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1884 // ParameterName::IndexFormatSpecifier
1885 skip |= validate_struct_type_array(
1886 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1887 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
1888 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages,
1889 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1890 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06001891 "VUID-VkGraphicsPipelineCreateInfo-pStages-06600");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001892 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1893 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1894 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
1895 pCreateInfos[i].pRasterizationState,
1896 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1897 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1898 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001899 }
1900
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001901 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1902 if (create_info.pDynamicState != nullptr) {
1903 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001904 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1905 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001906 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1907 if (has_dynamic_viewport == true) {
1908 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1909 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT 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_viewport = true;
1914 }
1915 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1916 if (has_dynamic_scissor == true) {
1917 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1918 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR 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_scissor = true;
1923 }
1924 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1925 if (has_dynamic_line_width == true) {
1926 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1927 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH 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_line_width = true;
1932 }
1933 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1934 if (has_dynamic_depth_bias == true) {
1935 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1936 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS 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_depth_bias = true;
1941 }
1942 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1943 if (has_dynamic_blend_constant == true) {
1944 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1945 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS 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_blend_constant = true;
1950 }
1951 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1952 if (has_dynamic_depth_bounds == true) {
1953 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1954 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001955 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001956 i);
1957 }
1958 has_dynamic_depth_bounds = true;
1959 }
1960 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1961 if (has_dynamic_stencil_compare == true) {
1962 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1963 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_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_compare = true;
1968 }
1969 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1970 if (has_dynamic_stencil_write == true) {
1971 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1972 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK 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_write = true;
1977 }
1978 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1979 if (has_dynamic_stencil_reference == true) {
1980 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1981 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001982 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001983 i);
1984 }
1985 has_dynamic_stencil_reference = true;
1986 }
1987 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1988 if (has_dynamic_viewport_w_scaling_nv == true) {
1989 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1990 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV 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_viewport_w_scaling_nv = true;
1995 }
1996 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1997 if (has_dynamic_discard_rectangle_ext == true) {
1998 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1999 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002000 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002001 i);
2002 }
2003 has_dynamic_discard_rectangle_ext = true;
2004 }
2005 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
2006 if (has_dynamic_sample_locations_ext == true) {
2007 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2008 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT 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_sample_locations_ext = true;
2013 }
2014 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
2015 if (has_dynamic_exclusive_scissor_nv == true) {
2016 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2017 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002018 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002019 i);
2020 }
2021 has_dynamic_exclusive_scissor_nv = true;
2022 }
2023 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
2024 if (has_dynamic_shading_rate_palette_nv == true) {
2025 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2026 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_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 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06002030 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07002031 }
2032 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
2033 if (has_dynamic_viewport_course_sample_order_nv == true) {
2034 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2035 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002036 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002037 i);
2038 }
2039 has_dynamic_viewport_course_sample_order_nv = true;
2040 }
2041 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
2042 if (has_dynamic_line_stipple == true) {
2043 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2044 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002045 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002046 i);
2047 }
2048 has_dynamic_line_stipple = true;
2049 }
Piers Daniell39842ee2020-07-10 16:42:33 -06002050 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
2051 if (has_dynamic_cull_mode) {
2052 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2053 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_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_cull_mode = true;
2058 }
2059 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
2060 if (has_dynamic_front_face) {
2061 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2062 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002063 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002064 i);
2065 }
2066 has_dynamic_front_face = true;
2067 }
2068 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
2069 if (has_dynamic_primitive_topology) {
2070 skip |= LogError(
2071 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2072 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002073 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002074 i);
2075 }
2076 has_dynamic_primitive_topology = true;
2077 }
2078 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2079 if (has_dynamic_viewport_with_count) {
2080 skip |= LogError(
2081 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2082 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002083 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002084 i);
2085 }
2086 has_dynamic_viewport_with_count = true;
2087 }
2088 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2089 if (has_dynamic_scissor_with_count) {
2090 skip |= LogError(
2091 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2092 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002093 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002094 i);
2095 }
2096 has_dynamic_scissor_with_count = true;
2097 }
2098 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2099 if (has_dynamic_vertex_input_binding_stride) {
2100 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2101 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2102 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002103 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002104 i);
2105 }
2106 has_dynamic_vertex_input_binding_stride = true;
2107 }
2108 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2109 if (has_dynamic_depth_test_enable) {
2110 skip |= LogError(
2111 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2112 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002113 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002114 i);
2115 }
2116 has_dynamic_depth_test_enable = true;
2117 }
2118 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2119 if (has_dynamic_depth_write_enable) {
2120 skip |= LogError(
2121 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2122 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002123 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002124 i);
2125 }
2126 has_dynamic_depth_write_enable = true;
2127 }
2128 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2129 if (has_dynamic_depth_compare_op) {
2130 skip |=
2131 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2132 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002133 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002134 i);
2135 }
2136 has_dynamic_depth_compare_op = true;
2137 }
2138 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2139 if (has_dynamic_depth_bounds_test_enable) {
2140 skip |= LogError(
2141 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2142 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002143 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002144 i);
2145 }
2146 has_dynamic_depth_bounds_test_enable = true;
2147 }
2148 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2149 if (has_dynamic_stencil_test_enable) {
2150 skip |= LogError(
2151 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2152 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_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_test_enable = true;
2157 }
2158 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2159 if (has_dynamic_stencil_op) {
2160 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2161 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002162 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002163 i);
2164 }
2165 has_dynamic_stencil_op = true;
2166 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002167 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2168 // Not allowed for graphics pipelines
2169 skip |= LogError(
2170 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2171 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002172 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2173 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002174 i, state_index);
2175 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002176 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2177 if (has_patch_control_points) {
2178 skip |= LogError(
2179 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2180 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002181 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002182 i);
2183 }
2184 has_patch_control_points = true;
2185 }
2186 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2187 if (has_rasterizer_discard_enable) {
2188 skip |= LogError(
2189 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2190 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002191 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002192 i);
2193 }
2194 has_rasterizer_discard_enable = true;
2195 }
2196 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2197 if (has_depth_bias_enable) {
2198 skip |= LogError(
2199 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2200 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_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_depth_bias_enable = true;
2205 }
2206 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2207 if (has_logic_op) {
2208 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2209 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002210 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002211 i);
2212 }
2213 has_logic_op = true;
2214 }
2215 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2216 if (has_primitive_restart_enable) {
2217 skip |= LogError(
2218 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2219 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002220 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002221 i);
2222 }
2223 has_primitive_restart_enable = true;
2224 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002225 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2226 if (has_dynamic_vertex_input) {
2227 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002228 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2229 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2230 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002231 }
2232 has_dynamic_vertex_input = true;
2233 }
Petr Kraus299ba622017-11-24 03:09:03 +01002234 }
2235 }
2236
sfricke-samsung3b944422021-01-23 02:15:19 -08002237 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2238 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2239 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002240 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2241 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002242 i);
2243 }
2244
2245 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2246 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2247 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002248 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002249 i);
2250 }
2251
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002252 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2253 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002254 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002255 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2256 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2257 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002258 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002259 }
2260
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002262
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002263 // Collect active stages and other information
2264 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002265 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002266 bool has_eval = false;
2267 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002268 if (create_info.pStages != nullptr) {
2269 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2270 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002271
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002272 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002273 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002274 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002275 has_eval = true;
2276 }
2277
Tony-LunarGd29cc032022-05-13 14:38:27 -06002278 skip |= validate_required_pointer(
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002279 "vkCreateGraphicsPipelines",
Tony-LunarGd29cc032022-05-13 14:38:27 -06002280 ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}),
2281 create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter");
2282
2283 if (create_info.pStages[stage_index].pName) {
2284 skip |= validate_string(
2285 "vkCreateGraphicsPipelines",
2286 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2287 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
2288 }
ziga-lunargc6341372021-07-28 12:57:42 +02002289
2290 std::stringstream msg;
2291 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2292 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002293 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002294 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002295 }
2296
2297 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002298 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2299 skip |=
2300 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2301 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2302 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2303 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002304
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002305 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002306 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2307
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002308 skip |= validate_struct_pnext(
2309 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002310 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002311 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2312 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2313 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2314 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002315
2316 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002317 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002318 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2319 }
2320
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002321 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002322 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2323 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002324 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002325 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2326 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2327
2328 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002329 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002330 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002331
2332 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002333 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002334 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2335
2336 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2337 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002338 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002339 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2340
2341 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002342 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002343 }
2344
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002345 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2346 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002347
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002348 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002349 skip |=
2350 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2351 "vkCreateGraphicsPipelines: pararameter "
2352 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2353 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002354 }
2355
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002356 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002357 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002358 skip |=
2359 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2360 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2361 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2362 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2363 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002364 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2365 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002366 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002367 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2368 skip |=
2369 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2370 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002371 create_info.pVertexInputState->vertexBindingDescriptionCount,
2372 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002373 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2374
2375 skip |= validate_array(
2376 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2377 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2378 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2379 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2380
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002381 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002382 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002383 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002384 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002385 skip |= validate_ranged_enum(
2386 "vkCreateGraphicsPipelines",
2387 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2388 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002389 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002390 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2391 }
2392 }
2393
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002394 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002395 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002396 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002397 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002398 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002399 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002400 skip |= validate_ranged_enum(
2401 "vkCreateGraphicsPipelines",
2402 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2403 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002404 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002405 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002406 if (FormatIsDepthOrStencil(format)) {
2407 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2408 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2409 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2410 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002411 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2412 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002413 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2414 "alignment, replace with a color format.",
2415 i, vertex_attribute_description_index, string_VkFormat(format));
2416 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002417 }
2418 }
2419
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002420 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2422 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002423 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2424 ") is "
2425 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002426 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002427 }
2428
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002429 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002430 skip |=
2431 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2432 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002433 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2434 ") is "
2435 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002436 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002437 }
2438
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002439 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002440 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2441 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002442 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2443 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002444 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2445 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002446 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2447 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002448 "(%" PRIu32 ") is not distinct.",
2449 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002450 }
2451 vertex_bindings.insert(vertex_bind_desc.binding);
2452
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002453 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002454 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2455 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002456 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2457 "].binding (%" PRIu32
2458 ") is "
2459 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002460 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 }
2462
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002463 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002464 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2465 "vkCreateGraphicsPipelines: parameter "
2466 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2467 "].stride (%" PRIu32
2468 ") is greater "
2469 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2470 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002471 }
2472 }
2473
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002474 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002475 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2476 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002477 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2478 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002479 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2480 "vkCreateGraphicsPipelines: parameter "
2481 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2482 "].location (%" PRIu32 ") is not distinct.",
2483 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002484 }
2485 attribute_locations.insert(vertex_attrib_desc.location);
2486
2487 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2488 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002489 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2490 "vkCreateGraphicsPipelines: parameter "
2491 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2492 "].binding (%" PRIu32
2493 ") does not exist "
2494 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2495 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002496 }
2497
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002498 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2500 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002501 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2502 "].location (%" PRIu32
2503 ") is "
2504 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002505 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002506 }
2507
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002508 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002509 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2510 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002511 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2512 "].binding (%" PRIu32
2513 ") is "
2514 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002515 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002516 }
2517
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002518 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002519 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2520 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002521 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2522 "].offset (%" PRIu32
2523 ") is "
2524 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002525 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002526 }
2527 }
2528 }
2529
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002530 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2531 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002532 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002533 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002534 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2535 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002536 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002537 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002538 i, i);
2539 } else {
2540 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2541 skip |= validate_struct_pnext(
2542 "vkCreateGraphicsPipelines",
2543 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002544 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002545 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2546 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002547
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002548 skip |= validate_reserved_flags(
2549 "vkCreateGraphicsPipelines",
2550 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002551 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002552
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002553 if (create_info.pTessellationState->patchControlPoints == 0 ||
2554 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2555 skip |=
2556 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2557 "vkCreateGraphicsPipelines: invalid parameter "
2558 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2559 ". patchControlPoints "
2560 "should be >0 and <=%" PRIu32 ".",
2561 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002562 }
2563 }
2564 }
2565
2566 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002567 if ((create_info.pRasterizationState != nullptr) &&
2568 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2569 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2571 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2572 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2573 "].pViewportState (=NULL) is not a valid pointer.",
2574 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002575 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002576 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002577
2578 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002579 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2580 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2581 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2582 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583 }
2584
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002585 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002586 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002587 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2588 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002589 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2590 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002591 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002592 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002594 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002595 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002596 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002597 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002598 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002599 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002600 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002601 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002602 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002603
2604 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002605 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002607 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002608
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002609 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002610 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002611 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002612 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002613 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002614 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2615 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002616 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002617 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2618 const auto depth_clip_control_struct =
2619 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002621 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002622 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002623 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2624 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2625 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2626 ") is not 1.",
2627 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002628 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002630 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002631 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2632 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2633 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2634 ") is not 1.",
2635 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002637
Dave Houlton142c4cb2018-10-17 15:04:41 -06002638 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2639 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002640 skip |= LogError(
2641 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2642 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2643 "disabled, but pCreateInfos[%" PRIu32
2644 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2645 ") is not 1.",
2646 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002647 }
2648
Jeff Bolz9af91c52018-09-01 21:53:57 -05002649 if (shading_rate_image_struct &&
2650 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002651 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2652 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2653 "disabled, but pCreateInfos[%" PRIu32
2654 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2655 ") is neither 0 nor 1.",
2656 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002657 }
2658
Petr Krausa6103552017-11-16 21:21:58 +01002659 } else { // multiViewport enabled
2660 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002661 if (!has_dynamic_viewport_with_count) {
2662 skip |= LogError(
2663 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2664 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2665 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002666 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002667 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2668 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2669 "].pViewportState->viewportCount (=%" PRIu32
2670 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2671 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002672 } else if (has_dynamic_viewport_with_count) {
2673 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2674 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2675 "].pViewportState->viewportCount (=%" PRIu32
2676 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2677 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002678 }
Petr Krausa6103552017-11-16 21:21:58 +01002679
2680 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002681 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002682 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2683 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2684 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002685 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002686 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002687 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2688 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002689 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002690 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2691 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2692 "].pViewportState->scissorCount (=%" PRIu32
2693 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2694 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002695 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002696 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2697 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2698 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2699 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002700 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2701 "].pViewportState->scissorCount (=%" PRIu32
2702 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2703 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002704 }
2705 }
2706
ziga-lunarg845883b2021-07-14 15:05:00 +02002707 if (!has_dynamic_scissor && viewport_state.pScissors) {
2708 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2709 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002710
2711 if (scissor.offset.x < 0) {
2712 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2713 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2714 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2715 scissor.offset.x, i, scissor_i);
2716 }
2717
2718 if (scissor.offset.y < 0) {
2719 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2720 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2721 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2722 scissor.offset.y, i, scissor_i);
2723 }
2724
ziga-lunarg845883b2021-07-14 15:05:00 +02002725 const int64_t x_sum =
2726 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2727 if (x_sum > std::numeric_limits<int32_t>::max()) {
2728 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2729 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2730 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2731 "] will overflow int32_t.",
2732 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2733 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002734
ziga-lunarg845883b2021-07-14 15:05:00 +02002735 const int64_t y_sum =
2736 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2737 if (y_sum > std::numeric_limits<int32_t>::max()) {
2738 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2739 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2740 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2741 "] will overflow int32_t.",
2742 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2743 }
2744 }
2745 }
2746
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002747 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002748 skip |=
2749 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2750 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2751 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2752 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002753 }
2754
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002755 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002756 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2757 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2758 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2759 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2760 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002761 }
2762
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002763 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2764 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2765 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2766 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2767 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2768 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2769 skip |= LogError(
2770 device, vuid,
2771 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2772 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2773 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2774 }
Petr Krausa6103552017-11-16 21:21:58 +01002775 }
2776
Dave Houlton142c4cb2018-10-17 15:04:41 -06002777 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002778 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002779 skip |=
2780 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2781 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2782 ") must be zero or identical to pCreateInfos[%" PRIu32
2783 "].pViewportState->viewportCount (=%" PRIu32 ").",
2784 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002785 }
2786
Dave Houlton142c4cb2018-10-17 15:04:41 -06002787 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002788 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002789 skip |= LogError(
2790 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002791 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2792 "] "
2793 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2794 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2795 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002796 }
2797
Petr Krausa6103552017-11-16 21:21:58 +01002798 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002799 skip |= LogError(
2800 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002801 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2802 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002803 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2804 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002805 }
2806
2807 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002808 skip |= LogError(
2809 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002810 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2811 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002812 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2813 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002814 }
2815
Jeff Bolz3e71f782018-08-29 23:15:45 -05002816 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002817 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2818 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2819 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002820 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2822 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2823 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2824 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002825 }
2826
Jeff Bolz9af91c52018-09-01 21:53:57 -05002827 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002828 shading_rate_image_struct->viewportCount > 0 &&
2829 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002830 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002831 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002832 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002833 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2834 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002835 i, i);
2836 }
2837
Chris Mayer328d8212018-12-11 14:16:18 +01002838 if (vp_swizzle_struct) {
2839 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002840 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2841 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2842 " does "
2843 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2844 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002845 }
2846 }
2847
Petr Krausb3fcdb42018-01-09 22:09:09 +01002848 // validate the VkViewports
2849 if (!has_dynamic_viewport && viewport_state.pViewports) {
2850 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2851 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002852 const char *fn_name = "vkCreateGraphicsPipelines";
2853 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2854 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2855 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002856 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002857 }
2858 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002859
sfricke-samsung45996a42021-09-16 13:45:27 -07002860 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002861 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2862 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2863 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2864 "VK_NV_clip_space_w_scaling extension is not enabled.",
2865 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002866 }
2867
sfricke-samsung45996a42021-09-16 13:45:27 -07002868 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2870 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2871 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2872 "VK_EXT_discard_rectangles extension is not enabled.",
2873 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002874 }
2875
sfricke-samsung45996a42021-09-16 13:45:27 -07002876 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002877 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2878 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2879 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2880 "VK_EXT_sample_locations extension is not enabled.",
2881 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002882 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002883
sfricke-samsung45996a42021-09-16 13:45:27 -07002884 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002885 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2886 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2887 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2888 "VK_NV_scissor_exclusive extension is not enabled.",
2889 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002890 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002891
2892 if (coarse_sample_order_struct &&
2893 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2894 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002895 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2896 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2897 "] "
2898 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2899 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2900 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002901 }
2902
2903 if (coarse_sample_order_struct) {
2904 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002905 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002906 }
2907 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002908
2909 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2910 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002911 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2912 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2913 "] "
2914 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2915 ") "
2916 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2917 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002918 }
2919 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002920 skip |= LogError(
2921 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002922 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2923 "] "
2924 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2925 i);
2926 }
2927 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002928
2929 if (depth_clip_control_struct) {
2930 const auto *depth_clip_control_features =
2931 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2932 const bool enabled_depth_clip_control =
2933 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2934 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2935 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2936 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2937 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2938 "depthClipControl feature is not enabled. ",
2939 i);
2940 }
2941 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002942 }
2943
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002944 const bool is_frag_out_graphics_lib =
2945 graphics_lib_info &&
2946 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002947 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002948 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002949 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2950 "].pRasterizationState->rasterizerDiscardEnable "
2951 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002952 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002954 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002955 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002956 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2957 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002958 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002959 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002960 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002962 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002963 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002964 skip |= validate_struct_pnext(
2965 "vkCreateGraphicsPipelines",
2966 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002967 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002968 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2969 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002971 skip |= validate_reserved_flags(
2972 "vkCreateGraphicsPipelines",
2973 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002974 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002976 skip |= validate_bool32(
2977 "vkCreateGraphicsPipelines",
2978 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002979 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002981 skip |= validate_array(
2982 "vkCreateGraphicsPipelines",
2983 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2984 ParameterName::IndexVector{i}),
2985 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002986 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2987 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002988
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002989 skip |= validate_flags("vkCreateGraphicsPipelines",
2990 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2991 ParameterName::IndexVector{i}),
2992 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002993 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002994 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002996 skip |= validate_bool32("vkCreateGraphicsPipelines",
2997 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2998 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002999 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003001 skip |= validate_bool32(
3002 "vkCreateGraphicsPipelines",
3003 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003004 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003005
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003006 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003007 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
3008 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3009 "].pMultisampleState->sType must be "
3010 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003011 i);
John Zulauf7acac592017-11-06 11:15:53 -07003012 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003013 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003014 if (!physical_device_features.sampleRateShading) {
3015 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
3016 "vkCreateGraphicsPipelines(): parameter "
3017 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
3018 i);
3019 }
3020 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
3021 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003022 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003023 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003024
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003025 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
3026 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
3027 "].pMultisampleState->minSampleShading.",
3028 i);
3029 }
John Zulauf7acac592017-11-06 11:15:53 -07003030 }
3031 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003032
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003033 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003034 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003035
3036 if (line_state) {
3037 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
3038 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003039 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003040 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003041 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3042 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003043 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003044 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003045 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003046 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003047 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003048 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3049 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003050 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003051 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003052 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003053 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003054 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003055 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3056 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003057 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003059 }
3060 }
3061 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3062 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3063 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003064 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003065 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3066 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003067 "range [1,256].",
3068 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003069 }
3070 }
3071 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003072 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003073 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3074 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003075 skip |=
3076 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
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_RECTANGULAR_EXT requires the rectangularLines feature.",
3080 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003081 }
3082 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3083 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003084 skip |=
3085 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
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_BRESENHAM_EXT requires the bresenhamLines feature.",
3089 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003090 }
3091 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3092 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003093 skip |=
3094 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003095 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3096 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003097 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3098 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003099 }
3100 if (line_state->stippledLineEnable) {
3101 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3102 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003103 skip |=
3104 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003105 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3106 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003107 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3108 "stippledRectangularLines feature.",
3109 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003110 }
3111 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3112 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003113 skip |=
3114 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003115 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3116 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003117 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3118 "stippledBresenhamLines feature.",
3119 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003120 }
3121 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3122 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003123 skip |=
3124 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003125 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3126 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003127 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3128 "stippledSmoothLines feature.",
3129 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003130 }
3131 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003132 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003133 skip |=
3134 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003135 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3136 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003137 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3138 "stippledRectangularLines and strictLines features.",
3139 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003140 }
3141 }
3142 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003143 }
3144
Petr Krause91f7a12017-12-14 20:57:36 +01003145 bool uses_color_attachment = false;
3146 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003147 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003148 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003149 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003150 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003151 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003152 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003153 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003154 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003155 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003156 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003157 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003158 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003159 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003160 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003161 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003162 }
3163
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003164 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003165 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003166 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003167 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003168 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003169 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170
Mike Schuchardt00e81452021-11-29 11:11:20 -08003171 skip |=
3172 validate_flags("vkCreateGraphicsPipelines",
3173 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3174 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003175 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003176 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003177
3178 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003179 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003180 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003181 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182
3183 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003184 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003185 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003186 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003187
3188 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003189 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003191 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003192 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193
3194 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003195 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003196 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003197 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003198
3199 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003200 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003201 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003202 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003203
3204 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003205 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003206 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003207 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003208 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209
3210 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003211 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003212 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003213 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003214 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215
3216 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003217 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003219 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003220 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221
3222 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003223 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003225 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003226 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003227
3228 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003229 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003230 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003231 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003232 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233
3234 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003235 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003236 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003237 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003238 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239
3240 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003241 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003243 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003244 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003245
3246 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003247 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003248 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003249 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003250 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003251
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003252 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003253 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003254 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3255 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003256 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3257 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003258 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003259
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003260 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003261 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3262 const auto *rasterization_order_attachment_access_feature =
3263 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3264 const bool rasterization_order_depth_attachment_access_feature_enabled =
3265 rasterization_order_attachment_access_feature &&
3266 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3267 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3268 skip |= LogError(
3269 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3270 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3271 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3272 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003273 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003274 }
3275
3276 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3277 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003278 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003279 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3280 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003281 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003282 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3283 }
3284 }
3285
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003286 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003287 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3288 const auto *rasterization_order_attachment_access_feature =
3289 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3290 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3291 rasterization_order_attachment_access_feature &&
3292 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3293 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3294 skip |= LogError(
3295 device,
3296 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3297 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3298 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3299 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003300 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003301 }
3302
3303 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3304 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003305 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003306 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3307 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003308 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003309 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3310 }
3311 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003312 }
3313
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003314 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003315 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3316 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003317
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003318 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3319 skip |=
3320 validate_struct_type("vkCreateGraphicsPipelines",
3321 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3322 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3323 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3324 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003325
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003326 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003327 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003328 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003329 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3330 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003331 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003332 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3333 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003334
Mike Schuchardt00e81452021-11-29 11:11:20 -08003335 skip |= validate_flags("vkCreateGraphicsPipelines",
3336 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3337 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003338 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003339 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003340
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003341 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003342 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3343 const auto *rasterization_order_attachment_access_feature =
3344 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3345 const bool rasterization_order_color_attachment_access_feature_enabled =
3346 rasterization_order_attachment_access_feature &&
3347 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3348
3349 if (!rasterization_order_color_attachment_access_feature_enabled) {
3350 skip |= LogError(
3351 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3352 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3353 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3354 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003355 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003356 }
3357
3358 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003359 skip |=
3360 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3361 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3362 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3363 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3364 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003365 }
3366 }
3367
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003368 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003369 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003370 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003371 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003372
3373 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003374 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003375 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3376 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003377 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3378 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003379
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003380 if (create_info.pColorBlendState->pAttachments != NULL) {
3381 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003382 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003383 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003384 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003385 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003386 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003387
3388 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003389 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003390 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003391 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003392 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003393 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003394 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395
3396 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003397 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003398 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003399 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003400 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003401 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003402 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003403
3404 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003405 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003406 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003407 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003408 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003409 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003410 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003411
3412 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003413 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003414 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003415 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003416 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003417 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003418 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003419
3420 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003421 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003422 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003423 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003424 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003425 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003426 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427
3428 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003429 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003431 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003433 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003434 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435
3436 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003437 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003439 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003440 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003441 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003442 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003443
3444 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3445 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003446 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003447 case VK_BLEND_OP_ZERO_EXT:
3448 case VK_BLEND_OP_SRC_EXT:
3449 case VK_BLEND_OP_DST_EXT:
3450 case VK_BLEND_OP_SRC_OVER_EXT:
3451 case VK_BLEND_OP_DST_OVER_EXT:
3452 case VK_BLEND_OP_SRC_IN_EXT:
3453 case VK_BLEND_OP_DST_IN_EXT:
3454 case VK_BLEND_OP_SRC_OUT_EXT:
3455 case VK_BLEND_OP_DST_OUT_EXT:
3456 case VK_BLEND_OP_SRC_ATOP_EXT:
3457 case VK_BLEND_OP_DST_ATOP_EXT:
3458 case VK_BLEND_OP_XOR_EXT:
3459 case VK_BLEND_OP_INVERT_EXT:
3460 case VK_BLEND_OP_INVERT_RGB_EXT:
3461 case VK_BLEND_OP_LINEARDODGE_EXT:
3462 case VK_BLEND_OP_LINEARBURN_EXT:
3463 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3464 case VK_BLEND_OP_LINEARLIGHT_EXT:
3465 case VK_BLEND_OP_PINLIGHT_EXT:
3466 case VK_BLEND_OP_HARDMIX_EXT:
3467 case VK_BLEND_OP_PLUS_EXT:
3468 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3469 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3470 case VK_BLEND_OP_PLUS_DARKER_EXT:
3471 case VK_BLEND_OP_MINUS_EXT:
3472 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3473 case VK_BLEND_OP_CONTRAST_EXT:
3474 case VK_BLEND_OP_INVERT_OVG_EXT:
3475 case VK_BLEND_OP_RED_EXT:
3476 case VK_BLEND_OP_GREEN_EXT:
3477 case VK_BLEND_OP_BLUE_EXT:
3478 invalid = true;
3479 break;
3480 default:
3481 break;
3482 }
3483 if (invalid) {
3484 skip |= LogError(
3485 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3486 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3487 "].pColorBlendState->pAttachments[%" PRIu32
3488 "].colorBlendOp (%s) is not valid when "
3489 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3490 "VK_FALSE",
3491 i, attachment_index,
3492 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003493 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003494 }
3495 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003496 }
3497 }
3498
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003499 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003500 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003501 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3502 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003503 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3504 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505 }
3506
3507 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003508 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003509 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003510 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003512 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003513 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003514 }
3515 }
3516 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003517
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003518 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003519 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003520 if (create_info.basePipelineIndex != -1) {
3521 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003522 skip |=
3523 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003524 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3525 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003527 "and pCreateInfos->basePipelineIndex is not -1.",
3528 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003529 }
3530 }
3531
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003532 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3533 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003534 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003535 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3536 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003537 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003538 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3539 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003541 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003542 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003543 skip |=
3544 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003545 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3546 ") must be a valid"
3547 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003548 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003549 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003550 }
3551 }
3552
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003553 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003554 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003555 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003556 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003557 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3558 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3559 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3560 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003561 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003562 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003563 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003564 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003565 "pCreateInfos[%" PRIu32
3566 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003567 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3568 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003569 }
3570 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003571 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3572 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003573 (physical_device_features.fillModeNonSolid == false)) {
3574 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003575 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3576 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003577 "pCreateInfos[%" PRIu32
3578 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003579 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3580 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003581 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003582 }
Petr Kraus299ba622017-11-24 03:09:03 +01003583
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003584 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003585 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003586 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3587 "The line width state is static (pCreateInfos[%" PRIu32
3588 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3589 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3590 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003591 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003592 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003593 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003594
3595 // Validate no flags not allowed are used
3596 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003597 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003598 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3599 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003600 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3601 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003602 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003603 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3604 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003605 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003606 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3607 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003608 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3609 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003610 }
3611 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3612 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003613 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3614 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003615 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3616 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003617 }
3618 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3619 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003620 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3621 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003622 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3623 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003624 }
3625 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3626 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003627 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3628 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003629 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3630 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003631 }
3632 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3633 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003634 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3635 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003636 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3637 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003638 }
3639 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3640 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003641 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3642 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003643 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3644 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003645 }
3646 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3647 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003648 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3649 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003650 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3651 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003652 }
3653 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3654 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003655 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3656 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003657 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3658 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003659 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003660 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3661 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3662 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3663 "]->flags (0x%x) must not include "
3664 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3665 i, flags);
3666 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003667 }
3668 }
3669
3670 return skip;
3671}
3672
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003673bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3674 uint32_t createInfoCount,
3675 const VkComputePipelineCreateInfo *pCreateInfos,
3676 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003677 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003678 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003679 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003680 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003681 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003682 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003683 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003684 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3685 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003686 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003687 skip |= LogError(
3688 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3689 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3690 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3691 feedback_count, i);
3692 }
Peter Chen85366392019-05-14 15:20:11 -04003693 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003694
3695 // Make sure compute stage is selected
3696 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003697 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003698 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3699 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003700 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003701 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003702
sfricke-samsungeb549012021-04-16 01:25:51 -07003703 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3704 // Validate no flags not allowed are used
3705 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003706 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3707 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3708 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3709 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003710 }
3711 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3712 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003713 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3714 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003715 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3716 i, flags);
3717 }
3718 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3719 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003720 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3721 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003722 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3723 i, flags);
3724 }
3725 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3726 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003727 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3728 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003729 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3730 i, flags);
3731 }
3732 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3733 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003734 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3735 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003736 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3737 i, flags);
3738 }
3739 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3740 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003741 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3742 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003743 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3744 i, flags);
3745 }
3746 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3747 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003748 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3749 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003750 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3751 i, flags);
3752 }
3753 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3754 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003755 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3756 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003757 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3758 i, flags);
3759 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003760 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3761 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003762 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3763 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003764 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3765 i, flags);
3766 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003767 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3768 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003769 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3770 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003771 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3772 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003773 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003774 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3775 if (pCreateInfos[i].basePipelineIndex != -1) {
3776 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3777 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3778 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3779 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3780 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3781 i);
3782 }
3783 }
3784
3785 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3786 if (pCreateInfos[i].basePipelineIndex != -1) {
3787 skip |= LogError(
3788 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3789 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3790 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3791 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3792 i);
3793 }
3794 } else {
3795 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3796 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3797 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3798 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3799 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3800 }
3801 }
3802 }
ziga-lunargc6341372021-07-28 12:57:42 +02003803
3804 std::stringstream msg;
3805 msg << "pCreateInfos[%" << i << "].stage";
3806 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003807 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003808 return skip;
3809}
3810
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003811bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003812 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003813 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003814
3815 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003816 const auto &features = physical_device_features;
3817 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003818
John Zulauf71968502017-10-26 13:51:15 -06003819 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3820 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003821 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3822 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3823 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3824 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003825 }
3826
3827 // Anistropy cannot be enabled in sampler unless enabled as a feature
3828 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003829 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3830 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3831 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003832 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003833 }
John Zulauf71968502017-10-26 13:51:15 -06003834
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003835 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3836 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003837 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3838 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3839 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3840 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003841 }
3842 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003843 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3844 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3845 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3846 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003847 }
3848 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003849 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3850 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3851 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3852 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003853 }
3854 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3855 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3856 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3857 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003858 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3859 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3860 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3861 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3862 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3863 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003864 }
3865 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003866 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3867 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3868 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003869 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003870 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003871 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3872 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3873 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003874 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003875 }
3876
3877 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003878 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003879 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003880 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3881 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003882 if (sampler_reduction != nullptr) {
3883 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003884 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3885 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
3886 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003887 }
3888 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003889 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003890 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003891 if (!IsExtEnabled(device_extensions.vk_ext_sampler_filter_minmax)) {
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003892 skip |= LogError(device, "VUID-VkSamplerCreateInfo-pNext-06726",
sjfricke751b7092022-04-12 21:49:37 +09003893 "vkCreateSampler(): sampler reduction mode is %s, but extension %s is not enabled.",
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003894 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3895 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
3896 }
ziga-lunarg01be97a2022-05-01 14:30:39 +02003897
3898 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
3899 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
3900 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
3901 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
3902 "extension %s is not enabled.",
3903 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3904 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
3905 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
3906 }
3907 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003908 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003909
3910 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3911 // valid VkBorderColor value
3912 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3913 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3914 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003915 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3916 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003917 }
3918
John Zulauf275805c2017-10-26 15:34:49 -06003919 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003920 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003921 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3922 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003923 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3924 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3925 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003926 }
3927 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003928
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003929 // Check for valid Lod range
3930 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003931 skip |=
3932 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3933 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003934 }
3935
3936 // Check mipLodBias to device limit
3937 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003938 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3939 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3940 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003941 }
3942
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003943 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003944 if (sampler_conversion != nullptr) {
3945 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3946 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3947 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3948 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003949 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003950 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003951 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3952 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3953 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3954 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3955 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3956 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3957 }
3958 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003959
3960 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3961 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3962 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3963 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3964 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3965 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3966 }
3967 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3968 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3969 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3970 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3971 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3972 }
3973 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3974 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3975 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3976 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3977 pCreateInfo->minLod, pCreateInfo->maxLod);
3978 }
3979 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3980 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3981 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3982 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3983 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3984 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3985 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3986 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3987 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3988 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3989 }
3990 if (pCreateInfo->anisotropyEnable) {
3991 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3992 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3993 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3994 }
3995 if (pCreateInfo->compareEnable) {
3996 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3997 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3998 "pCreateInfo->compareEnable must be VK_FALSE");
3999 }
4000 if (pCreateInfo->unnormalizedCoordinates) {
4001 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
4002 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
4003 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
4004 }
4005 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004006
Piers Daniell833b9492021-11-20 11:47:10 -07004007 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
4008 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
4009 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
4010 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4011 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
4012 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
4013 }
4014 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
4015 if (!custom_create_info) {
4016 skip |= LogError(
4017 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
4018 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
4019 "struct in pNext chain.\n",
4020 string_VkBorderColor(pCreateInfo->borderColor));
4021 } else {
4022 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
4023 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
4024 !FormatIsSampledInt(custom_create_info->format)) ||
4025 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
4026 !FormatIsSampledFloat(custom_create_info->format)))) {
4027 skip |=
4028 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06004029 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
4030 "whose type does not match\n",
4031 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07004032 ;
4033 }
4034 }
4035 }
4036
4037 const auto *border_color_component_mapping =
4038 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
4039 if (border_color_component_mapping) {
4040 const auto *border_color_swizzle_features =
4041 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4042 bool border_color_swizzle_features_enabled =
4043 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4044 if (!border_color_swizzle_features_enabled) {
4045 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4046 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4047 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004048 }
4049 }
4050 }
4051
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004052 return skip;
4053}
4054
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004055bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
4056 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4057 const char *func_name) const {
4058 bool skip = false;
4059
4060 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4061 uint32_t mutable_type_count = 0;
4062 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4063 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4064 }
4065 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4066 if (mutable_type_count == 0) {
4067 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4068 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4069 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4070 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4071 "].descriptorTypeCount is 0.",
4072 func_name, i, i);
4073 }
4074 } else {
4075 if (mutable_type_count > 0) {
4076 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4077 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4078 "].descriptorType is %s, but "
4079 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4080 "].descriptorTypeCount is not 0.",
4081 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4082 }
4083 }
4084 }
4085
4086 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4087 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4088 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
4089 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4090 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4091 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4092 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4093 func_name, j, k);
4094 break;
4095 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4096 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4097 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4098 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4099 func_name, j, k);
4100 break;
4101 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4102 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4103 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4104 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4105 func_name, j, k);
4106 break;
4107 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4108 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4109 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4110 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4111 func_name, j, k);
4112 break;
4113 default:
4114 break;
4115 }
4116 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4117 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4118 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4119 skip |=
4120 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4121 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4122 "].pDescriptorTypes[%" PRIu32
4123 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4124 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4125 func_name, j, k, j, l,
4126 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4127 }
4128 }
4129 }
4130 }
4131
4132 return skip;
4133}
4134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004135bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4136 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4137 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004138 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004139 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004140
ziga-lunargfc6896f2021-10-15 18:46:12 +02004141 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4142 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4143 bool mutable_descriptor_type_features_enabled =
4144 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4145
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004146 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4147 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4148 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4149 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004150 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4151 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4152 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4153 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4154 ++descriptor_index) {
4155 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004156 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004157 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004158 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4159 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004160 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004161 }
4162 }
4163 }
4164
4165 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4166 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4167 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004168 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004169 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4170 "].descriptorCount is not 0, "
4171 "pCreateInfo->pBindings[%" PRIu32
4172 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004173 "values.",
4174 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004175 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004176
4177 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4178 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4179 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004180 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4181 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4182 "].descriptorCount is not 0 and "
4183 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4184 "].stageFlags "
4185 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4186 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004187 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004188
4189 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4190 if (!mutable_descriptor_type) {
4191 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4192 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4193 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4194 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4195 i);
4196 }
4197 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4198 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4199 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4200 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4201 "pImmutableSamplers is not NULL.",
4202 i);
4203 }
4204 if (!mutable_descriptor_type_features_enabled) {
4205 skip |= LogError(
4206 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4207 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4208 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4209 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4210 i);
4211 }
4212 }
4213
4214 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4215 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4216 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4217 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4218 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4219 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004221 }
4222 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004223
4224 if (mutable_descriptor_type) {
4225 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4226 "vkDescriptorSetLayoutCreateInfo");
4227 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004228 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004229 if (pCreateInfo) {
4230 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4231 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4232 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4233 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4234 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4235 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4236 }
4237 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4238 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4239 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4240 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4241 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4242 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4243 }
4244 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4245 !mutable_descriptor_type_features_enabled) {
4246 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4247 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4248 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4249 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4250 }
4251 }
4252
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004253 return skip;
4254}
4255
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004256bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4257 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004258 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004259 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4260 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4261 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004262 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4263 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004264}
4265
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004266bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4267 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004268 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004269 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004270
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004271 if (pDescriptorWrites != NULL) {
4272 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4273 // descriptorCount must be greater than 0
4274 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004275 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4276 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4277 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004278 }
4279
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004280 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004281 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004282 // dstSet must be a valid VkDescriptorSet handle
4283 skip |= validate_required_handle(vkCallingFunction,
4284 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4285 pDescriptorWrites[i].dstSet);
4286 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004287
4288 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4289 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4290 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4291 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4292 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004293 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004294 if (!isPushDescriptor) {
4295 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4296 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4297 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4298 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4299 // ObjectLifetimes::ValidateDescriptorWrite.
4300 skip |= LogError(
4301 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4302 "%s(): if pDescriptorWrites[%" PRIu32
4303 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4304 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4305 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4306 vkCallingFunction, i, i);
4307 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4308 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4309 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4310 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4311 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4312 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4313 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4314 "%s(): if pDescriptorWrites[%" PRIu32
4315 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4316 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4317 "].pImageInfo must not be NULL.",
4318 vkCallingFunction, i, i);
4319 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004320 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4321 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004322 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4323 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004324 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4325 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004326 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004327 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4328 ParameterName::IndexVector{i, descriptor_index}),
4329 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004330 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004331 }
4332 }
4333 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4334 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4335 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4336 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4337 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4338 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4339 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004340 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004341 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004342 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004343 "%s(): if pDescriptorWrites[%" PRIu32
4344 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004345 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4346 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004347 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004348 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004349 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004350 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004351 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004352 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004353 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4354 ++descriptor_index) {
4355 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4356 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4357 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004358 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004359 "%s(): if pDescriptorWrites[%" PRIu32
4360 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004361 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004362 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4363 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004364 }
4365 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004366 }
4367 }
4368 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4369 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004370 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004371 }
4372
4373 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4374 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004375 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004376 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4377 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004378 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004379 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004380 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004381 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004382 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004383 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004384 }
4385 }
4386 }
4387 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4388 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004389 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004390 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4391 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004392 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004393 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004394 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004395 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004396 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004397 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004398 }
4399 }
4400 }
4401 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004402 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4403 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004404 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004405 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004406 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4407 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4408 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4409 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004410 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004411 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4412 pDescriptorWrites[i].descriptorCount);
4413 }
4414 // further checks only if we have right structtype
4415 if (pnext_struct) {
4416 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4417 skip |= LogError(
4418 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004419 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4420 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004421 ".",
4422 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004423 }
sourav parmarbcee7512020-12-28 14:34:49 -08004424 if (pnext_struct->accelerationStructureCount == 0) {
4425 skip |= LogError(device,
4426 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004427 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004428 }
4429 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004430 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004431 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4432 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4433 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4434 skip |= LogError(device,
4435 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4436 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004437 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004438 }
4439 }
4440 }
sourav parmarbcee7512020-12-28 14:34:49 -08004441 }
4442 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004443 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004444 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4445 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4446 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4447 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004448 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004449 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4450 pDescriptorWrites[i].descriptorCount);
4451 }
4452 // further checks only if we have right structtype
4453 if (pnext_struct) {
4454 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4455 skip |= LogError(
4456 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004457 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4458 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004459 ".",
4460 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004461 }
sourav parmarbcee7512020-12-28 14:34:49 -08004462 if (pnext_struct->accelerationStructureCount == 0) {
4463 skip |= LogError(device,
4464 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004465 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004466 }
4467 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004468 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004469 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4470 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4471 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4472 skip |= LogError(device,
4473 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4474 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004475 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004476 }
4477 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004478 }
4479 }
4480 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004481 }
4482 }
4483 return skip;
4484}
4485
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004486bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4487 const VkWriteDescriptorSet *pDescriptorWrites,
4488 uint32_t descriptorCopyCount,
4489 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004490 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004491}
4492
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004493bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004494 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004495 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004496 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4497}
4498
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004499bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4500 const VkAllocationCallbacks *pAllocator,
4501 VkRenderPass *pRenderPass) const {
4502 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4503}
4504
Mike Schuchardt2df08912020-12-15 16:28:09 -08004505bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004506 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004507 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004508 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4509}
4510
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004511bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4512 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004513 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004514 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004515
4516 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4517 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4518 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004519 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4520 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004521 return skip;
4522}
4523
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004524bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004525 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004526 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004527
4528 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4529 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004530 bool cb_is_secondary;
4531 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004532 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004533 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4534 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004535
Tony-LunarG3c287f62020-12-17 12:39:49 -07004536 if (cb_is_secondary) {
4537 // Implicit VUs
4538 // validate only sType here; pointer has to be validated in core_validation
4539 const bool k_not_required = false;
4540 const char *k_no_vuid = nullptr;
4541 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4542 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004543 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4544 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004545
Tony-LunarG3c287f62020-12-17 12:39:49 -07004546 if (info) {
4547 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004548 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004549 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4550 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004551 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004552 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004553 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4554 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4555 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4556 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004557
Tony-LunarG3c287f62020-12-17 12:39:49 -07004558 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004559
Tony-LunarG3c287f62020-12-17 12:39:49 -07004560 // Explicit VUs
4561 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004562 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004563 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4564 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4565 cmd_name);
4566 }
4567
4568 if (physical_device_features.inheritedQueries) {
4569 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004570 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4571 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4572 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004573 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004574 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004575 }
4576
4577 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004578 skip |=
4579 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4580 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4581 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4582 } else { // !pipelineStatisticsQuery
4583 skip |=
4584 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4585 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004586 }
4587
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004588 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004589 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004590 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004591 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4592 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4593 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004594 commandBuffer,
4595 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004596 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4597 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4598 }
Petr Kraus139757b2019-08-15 17:19:33 +02004599 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004600
4601 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4602 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4603 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4604 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4605 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4606 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4607 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4608 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4609 }
Petr Kraus139757b2019-08-15 17:19:33 +02004610 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004611 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004612 return skip;
4613}
4614
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004615bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004616 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004617 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004618
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004619 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004620 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004621 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4622 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4623 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004624 }
4625 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004626 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4627 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4628 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004629 }
4630 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004631 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004632 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004633 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4634 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4635 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4636 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004637 }
4638 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004639
4640 if (pViewports) {
4641 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4642 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004643 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004644 skip |= manual_PreCallValidateViewport(
4645 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004646 }
4647 }
4648
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004649 return skip;
4650}
4651
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004652bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004653 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004654 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004655
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004656 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004657 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004658 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4659 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4660 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004661 }
4662 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004663 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4664 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4665 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004666 }
4667 } else { // multiViewport enabled
4668 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004669 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004670 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4671 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4672 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4673 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004674 }
4675 }
4676
Petr Kraus6260f0a2018-02-27 21:15:55 +01004677 if (pScissors) {
4678 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4679 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004680
Petr Kraus6260f0a2018-02-27 21:15:55 +01004681 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004682 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4683 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4684 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004685 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004686
Petr Kraus6260f0a2018-02-27 21:15:55 +01004687 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004688 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4689 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4690 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004691 }
4692
4693 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4694 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004695 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4696 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4697 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4698 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004699 }
4700
4701 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4702 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004703 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4704 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4705 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4706 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004707 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004708 }
4709 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004710
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004711 return skip;
4712}
4713
Jeff Bolz5c801d12019-10-09 10:38:45 -05004714bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004715 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004716
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004717 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004718 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4719 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004720 }
4721
4722 return skip;
4723}
4724
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004725bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004726 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004727 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004728
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004729 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004730 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004731 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4732 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004733 }
4734 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004735 skip |=
4736 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4737 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4738 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004739 }
4740 return skip;
4741}
4742
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004743bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004744 VkDeviceSize offset, uint32_t drawCount,
4745 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004746 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004747 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004748 skip |=
4749 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4750 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4751 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004752 }
4753 if (drawCount > device_limits.maxDrawIndirectCount) {
4754 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004755 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4756 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004757 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004758 }
4759 return skip;
4760}
4761
sfricke-samsungf692b972020-05-02 08:00:45 -07004762bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4763 VkDeviceSize countBufferOffset, bool khr) const {
4764 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004765 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004766 if (offset & 3) {
4767 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004768 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004769 }
4770
4771 if (countBufferOffset & 3) {
4772 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004773 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004774 countBufferOffset);
4775 }
4776 return skip;
4777}
4778
4779bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4780 VkDeviceSize offset, VkBuffer countBuffer,
4781 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4782 uint32_t stride) const {
4783 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4784}
4785
4786bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4787 VkDeviceSize offset, VkBuffer countBuffer,
4788 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4789 uint32_t stride) const {
4790 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4791}
4792
4793bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4794 VkDeviceSize countBufferOffset, bool khr) const {
4795 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004796 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004797 if (offset & 3) {
4798 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004799 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004800 }
4801
4802 if (countBufferOffset & 3) {
4803 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004804 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004805 countBufferOffset);
4806 }
4807 return skip;
4808}
4809
4810bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4811 VkDeviceSize offset, VkBuffer countBuffer,
4812 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4813 uint32_t stride) const {
4814 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4815}
4816
4817bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4818 VkDeviceSize offset, VkBuffer countBuffer,
4819 VkDeviceSize countBufferOffset,
4820 uint32_t maxDrawCount, uint32_t stride) const {
4821 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4822}
4823
Tony-LunarG4490de42021-06-21 15:49:19 -06004824bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4825 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4826 uint32_t firstInstance, uint32_t stride) const {
4827 bool skip = false;
4828 if (stride & 3) {
4829 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4830 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4831 }
4832 if (drawCount && nullptr == pVertexInfo) {
4833 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4834 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4835 "one or more valid instances of VkMultiDrawInfoEXT structures");
4836 }
4837 return skip;
4838}
4839
4840bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4841 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4842 uint32_t instanceCount, uint32_t firstInstance,
4843 uint32_t stride, const int32_t *pVertexOffset) const {
4844 bool skip = false;
4845 if (stride & 3) {
4846 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4847 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4848 }
4849 if (drawCount && nullptr == pIndexInfo) {
4850 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4851 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4852 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4853 }
4854 return skip;
4855}
4856
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004857bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4858 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004859 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004860 bool skip = false;
4861 for (uint32_t rect = 0; rect < rectCount; rect++) {
4862 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004863 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004864 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004865 }
sfricke-samsung10867682020-04-25 02:20:39 -07004866 if (pRects[rect].rect.extent.width == 0) {
4867 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004868 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004869 }
4870 if (pRects[rect].rect.extent.height == 0) {
4871 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004872 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004873 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004874 }
4875 return skip;
4876}
4877
Andrew Fobel3abeb992020-01-20 16:33:22 -05004878bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4879 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4880 VkImageFormatProperties2 *pImageFormatProperties,
4881 const char *apiName) const {
4882 bool skip = false;
4883
4884 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004885 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004886 if (image_stencil_struct != nullptr) {
4887 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4888 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4889 // No flags other than the legal attachment bits may be set
4890 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4891 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004892 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4893 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4894 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4895 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4896 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004897 }
4898 }
4899 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004900 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4901 if (image_drm_format) {
4902 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4903 skip |= LogError(
4904 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4905 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4906 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4907 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4908 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004909 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4910 skip |= LogError(
4911 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4912 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4913 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4914 apiName, image_drm_format->queueFamilyIndexCount);
4915 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004916 } else {
4917 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4918 skip |= LogError(
4919 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4920 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4921 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4922 apiName);
4923 }
4924 }
4925 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4926 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4927 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4928 if (!format_list || format_list->viewFormatCount == 0) {
4929 skip |= LogError(
4930 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4931 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4932 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4933 apiName);
4934 }
4935 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004936 }
4937
4938 return skip;
4939}
4940
4941bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4942 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4943 VkImageFormatProperties2 *pImageFormatProperties) const {
4944 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4945 "vkGetPhysicalDeviceImageFormatProperties2");
4946}
4947
4948bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4949 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4950 VkImageFormatProperties2 *pImageFormatProperties) const {
4951 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4952 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4953}
4954
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004955bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4956 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4957 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4958 bool skip = false;
4959
4960 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4961 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4962 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4963 }
4964
4965 return skip;
4966}
4967
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004968bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4969 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4970 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4971 bool skip = false;
4972
4973 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4974 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4975 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4976 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4977 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4978 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4979 }
4980
ziga-lunarg42f884b2021-08-25 16:13:20 +02004981 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004982}
4983
sfricke-samsung3999ef62020-02-09 17:05:59 -08004984bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4985 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4986 bool skip = false;
4987
4988 if (pRegions != nullptr) {
4989 for (uint32_t i = 0; i < regionCount; i++) {
4990 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004991 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004992 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004993 }
4994 }
4995 }
4996 return skip;
4997}
4998
Jeff Leger178b1e52020-10-05 12:22:23 -04004999bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
5000 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
5001 bool skip = false;
5002
5003 if (pCopyBufferInfo->pRegions != nullptr) {
5004 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5005 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06005006 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005007 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04005008 }
5009 }
5010 }
5011 return skip;
5012}
5013
Tony-LunarGef035472021-11-02 10:23:33 -06005014bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
5015 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
5016 bool skip = false;
5017
5018 if (pCopyBufferInfo->pRegions != nullptr) {
5019 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
5020 if (pCopyBufferInfo->pRegions[i].size == 0) {
5021 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
5022 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
5023 }
5024 }
5025 }
5026 return skip;
5027}
5028
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005029bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005030 VkDeviceSize dstOffset, VkDeviceSize dataSize,
5031 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005032 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005033
5034 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005035 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5036 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5037 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005038 }
5039
5040 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005041 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5042 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5043 "), must be greater than zero and less than or equal to 65536.",
5044 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005045 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005046 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5047 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5048 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005049 }
5050 return skip;
5051}
5052
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005053bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005054 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005055 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005056
5057 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005058 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5059 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5060 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005061 }
5062
5063 if (size != VK_WHOLE_SIZE) {
5064 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005065 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005066 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5067 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005068 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005069 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5070 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005071 }
5072 }
5073 return skip;
5074}
5075
sfricke-samsunga1d00272021-03-10 21:37:41 -08005076bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005077 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005078
5079 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005080 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5081 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5082 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5083 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005084 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005085 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5086 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5087 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005088 }
5089
5090 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5091 // queueFamilyIndexCount uint32_t values
5092 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005093 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005094 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005095 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005096 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5097 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005098 }
5099 }
5100
Dave Houlton413a6782018-05-22 13:01:54 -06005101 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005102 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005103
sfricke-samsunga1d00272021-03-10 21:37:41 -08005104 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5105 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5106 if (format_list_info) {
5107 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5108 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5109 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5110 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005111 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5112 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005113 func_name, viewFormatCount);
5114 }
5115
5116 // Using the first format, compare the rest of the formats against it that they are compatible
5117 for (uint32_t i = 1; i < viewFormatCount; i++) {
5118 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5119 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5120 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5121 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005122 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5123 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005124 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5125 string_VkFormat(format_list_info->pViewFormats[i]));
5126 }
5127 }
5128 }
5129
5130 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5131 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5132 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5133 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5134 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5135 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5136 func_name);
5137 } else {
5138 if (format_list_info == nullptr) {
5139 skip |= LogError(
5140 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5141 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5142 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5143 func_name);
5144 } else if (format_list_info->viewFormatCount == 0) {
5145 skip |= LogError(
5146 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5147 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5148 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5149 func_name);
5150 } else {
5151 bool found_base_format = false;
5152 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5153 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5154 found_base_format = true;
5155 break;
5156 }
5157 }
5158 if (!found_base_format) {
5159 skip |=
5160 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5161 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5162 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5163 "pCreateInfo->imageFormat.",
5164 func_name);
5165 }
5166 }
5167 }
5168 }
5169 }
5170 return skip;
5171}
5172
5173bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5174 const VkAllocationCallbacks *pAllocator,
5175 VkSwapchainKHR *pSwapchain) const {
5176 bool skip = false;
5177 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5178 return skip;
5179}
5180
5181bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5182 const VkSwapchainCreateInfoKHR *pCreateInfos,
5183 const VkAllocationCallbacks *pAllocator,
5184 VkSwapchainKHR *pSwapchains) const {
5185 bool skip = false;
5186 if (pCreateInfos) {
5187 for (uint32_t i = 0; i < swapchainCount; i++) {
5188 std::stringstream func_name;
5189 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5190 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5191 }
5192 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005193 return skip;
5194}
5195
Jeff Bolz5c801d12019-10-09 10:38:45 -05005196bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005197 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005198
5199 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005200 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005201 if (present_regions) {
5202 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005203 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005204 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5205 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005206 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005207 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5208 "extension swapchainCount is %i. These values must be equal.",
5209 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005210 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005211 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005212 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5213 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005214 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5215 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5216 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005217 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005218 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005219 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005220 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005221 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005222 }
5223 }
5224
5225 return skip;
5226}
5227
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005228bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5229 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5230 const VkAllocationCallbacks *pAllocator,
5231 VkDisplayModeKHR *pMode) const {
5232 bool skip = false;
5233
5234 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5235 if (display_mode_parameters.visibleRegion.width == 0) {
5236 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5237 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5238 }
5239 if (display_mode_parameters.visibleRegion.height == 0) {
5240 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5241 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5242 }
5243 if (display_mode_parameters.refreshRate == 0) {
5244 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5245 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5246 }
5247
5248 return skip;
5249}
5250
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005251#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005252bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5253 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5254 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005255 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005256 bool skip = false;
5257
5258 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005259 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5260 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005261 }
5262
5263 return skip;
5264}
5265#endif // VK_USE_PLATFORM_WIN32_KHR
5266
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005267static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5268 bool partial_overlap = false;
5269
5270 static const std::vector<VkDescriptorType> all_descriptor_types = {
5271 VK_DESCRIPTOR_TYPE_SAMPLER,
5272 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5273 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5274 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5275 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5276 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5277 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5278 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5279 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5280 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5281 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5282 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5283 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5284 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5285 };
5286
5287 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5288 if (mutable_descriptor_type) {
5289 std::vector<VkDescriptorType> first_types, second_types;
5290 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5291 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5292 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5293 }
5294 } else {
5295 first_types = all_descriptor_types;
5296 }
5297 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5298 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5299 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5300 }
5301 } else {
5302 second_types = all_descriptor_types;
5303 }
5304
5305 bool complete_overlap = first_types.size() == second_types.size();
5306 bool disjoint = true;
5307 for (const auto first_type : first_types) {
5308 bool found = false;
5309 for (const auto second_type : second_types) {
5310 if (first_type == second_type) {
5311 found = true;
5312 break;
5313 }
5314 }
5315 if (found) {
5316 disjoint = false;
5317 } else {
5318 complete_overlap = false;
5319 }
5320 if (!disjoint && !complete_overlap) {
5321 partial_overlap = true;
5322 break;
5323 }
5324 }
5325 }
5326
5327 return partial_overlap;
5328}
5329
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005330bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005331 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005332 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005333 bool skip = false;
5334
5335 if (pCreateInfo) {
5336 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005337 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5338 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005339 }
5340
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005341 const auto *mutable_descriptor_type_features =
5342 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5343 bool mutable_descriptor_type_enabled =
5344 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5345
Petr Krausc8655be2017-09-27 18:56:51 +02005346 if (pCreateInfo->pPoolSizes) {
5347 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5348 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005349 skip |= LogError(
5350 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005351 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005352 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005353 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5354 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005355 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5356 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5357 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5358 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5359 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005360 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005361 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5362 skip |=
5363 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5364 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5365 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5366 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5367 i);
5368 }
5369 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5370 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5371 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5372 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5373 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5374 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5375 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5376 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5377 " and have sets which partially overlap.",
5378 i, j);
5379 }
5380 }
5381 }
5382 }
Petr Krausc8655be2017-09-27 18:56:51 +02005383 }
5384 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005385
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005386 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5387 skip |=
5388 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5389 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5390 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5391 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005392 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5393 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5394 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5395 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5396 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5397 }
Petr Krausc8655be2017-09-27 18:56:51 +02005398 }
5399
5400 return skip;
5401}
5402
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005403bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005404 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005405 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005406
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005407 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005408 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005409 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5410 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5411 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005412 }
5413
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005414 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005415 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005416 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5417 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5418 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005419 }
5420
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005421 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005422 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005423 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5424 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5425 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005426 }
5427
5428 return skip;
5429}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005430
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005431bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005432 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005433 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005434
5435 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005436 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5437 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005438 }
5439 return skip;
5440}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005441
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005442bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5443 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005444 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005445 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005446
5447 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005448 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005449 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005450 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5451 "vkCmdDispatch(): baseGroupX (%" PRIu32
5452 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5453 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005454 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005455 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5456 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5457 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5458 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005459 }
5460
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005461 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005462 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005463 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5464 "vkCmdDispatch(): baseGroupY (%" PRIu32
5465 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5466 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005467 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005468 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5469 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5470 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5471 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005472 }
5473
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005474 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005475 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005476 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5477 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5478 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5479 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005480 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005481 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5482 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5483 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5484 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005485 }
5486
5487 return skip;
5488}
5489
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005490bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5491 VkPipelineBindPoint pipelineBindPoint,
5492 VkPipelineLayout layout, uint32_t set,
5493 uint32_t descriptorWriteCount,
5494 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005495 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005496}
5497
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005498bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5499 uint32_t firstExclusiveScissor,
5500 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005501 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005502 bool skip = false;
5503
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005504 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005505 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005506 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005507 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5508 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5509 ") is not 0.",
5510 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005511 }
5512 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005513 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005514 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5515 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5516 ") is not 1.",
5517 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005518 }
5519 } else { // multiViewport enabled
5520 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005521 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005522 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5523 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5524 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5525 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005526 }
5527 }
5528
Jeff Bolz3e71f782018-08-29 23:15:45 -05005529 if (pExclusiveScissors) {
5530 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5531 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5532
5533 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005534 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5535 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5536 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005537 }
5538
5539 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005540 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5541 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5542 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005543 }
5544
5545 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5546 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005547 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5548 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5549 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5550 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005551 }
5552
5553 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5554 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005555 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5556 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5557 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5558 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005559 }
5560 }
5561 }
5562
5563 return skip;
5564}
5565
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005566bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5567 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005568 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005569 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005570 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5571 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5572 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5573 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5574 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5575 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005576 }
5577
5578 return skip;
5579}
5580
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005581bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5582 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005583 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005584 bool skip = false;
5585
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005586 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005587 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005588 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005589 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5590 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5591 ") is not 0.",
5592 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005593 }
5594 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005595 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005596 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5597 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5598 ") is not 1.",
5599 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005600 }
5601 }
5602
Jeff Bolz9af91c52018-09-01 21:53:57 -05005603 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005604 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005605 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5606 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5607 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5608 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005609 }
5610
5611 return skip;
5612}
5613
Jeff Bolz5c801d12019-10-09 10:38:45 -05005614bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5615 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5616 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005617 bool skip = false;
5618
Dave Houlton142c4cb2018-10-17 15:04:41 -06005619 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005620 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5621 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5622 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005623 }
5624
5625 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005626 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005627 }
5628
5629 return skip;
5630}
5631
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005632bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005633 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005634 bool skip = false;
5635
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005636 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005637 skip |= LogError(
5638 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005639 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5640 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005641 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005642 }
5643
5644 return skip;
5645}
5646
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005647bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5648 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005649 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005650 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005651 static const int condition_multiples = 0b0011;
5652 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005653 skip |= LogError(
5654 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005655 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005656 }
Lockee1c22882019-06-10 16:02:54 -06005657 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005658 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5659 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5660 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5661 stride);
Lockee1c22882019-06-10 16:02:54 -06005662 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005663 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005664 skip |= LogError(
5665 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005666 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5667 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005668 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005669 if (drawCount > device_limits.maxDrawIndirectCount) {
5670 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005671 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5672 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005673 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005674 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005675 return skip;
5676}
5677
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005678bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5679 VkDeviceSize offset, VkBuffer countBuffer,
5680 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005681 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005682 bool skip = false;
5683
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005684 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005685 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5686 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5687 "), is not a multiple of 4.",
5688 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005689 }
5690
5691 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005692 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5693 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5694 "), is not a multiple of 4.",
5695 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005696 }
5697
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005698 return skip;
5699}
5700
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005701bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005702 const VkAllocationCallbacks *pAllocator,
5703 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005704 bool skip = false;
5705
5706 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5707 if (pCreateInfo != nullptr) {
5708 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5709 // VkQueryPipelineStatisticFlagBits values
5710 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5711 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005712 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5713 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5714 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5715 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005716 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005717 if (pCreateInfo->queryCount == 0) {
5718 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5719 "vkCreateQueryPool(): queryCount must be greater than zero.");
5720 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005721 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005722 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005723}
5724
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005725bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5726 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005727 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005728 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5729 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005730}
5731
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005732void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005733 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5734 VkResult result) {
5735 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005736 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005737}
5738
Mike Schuchardt2df08912020-12-15 16:28:09 -08005739void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005740 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5741 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005742 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005743 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005744 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005745}
5746
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005747void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5748 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005749 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005750 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005751 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005752}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005753
Tony-LunarG3c287f62020-12-17 12:39:49 -07005754void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005755 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005756 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
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 < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005759 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005760 }
5761 }
5762}
5763
5764void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005765 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005766 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005767 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5768 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5769 }
5770}
5771
5772void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005773 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005774 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005775 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5776 if (item->second == commandPool) {
5777 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005778 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005779 ++item;
5780 }
5781 }
5782}
5783
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005784bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005785 const VkAllocationCallbacks *pAllocator,
5786 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005787 bool skip = false;
5788
5789 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005790 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005791 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005792 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5793 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005794 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005795
5796 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005797 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005798 if (flags_info) {
5799 flags = flags_info->flags;
5800 }
5801
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005802 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005803 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005804 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005805 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5806 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005807 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005808 }
5809
5810#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005811 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005812#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005813 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5814 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005815#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005816 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005817#endif
5818
5819 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005820 skip |= LogError(
5821 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005822 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5823 }
5824 if (
5825#ifdef VK_USE_PLATFORM_WIN32_KHR
5826 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5827#endif
5828 (import_memory_fd && import_memory_fd->handleType) ||
5829#ifdef VK_USE_PLATFORM_ANDROID_KHR
5830 (import_memory_ahb && import_memory_ahb->buffer) ||
5831#endif
5832 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005833 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5834 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005835 }
5836 }
5837
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005838 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5839 if (export_memory) {
5840 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5841 if (export_memory_nv) {
5842 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5843 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5844 "VkExportMemoryAllocateInfoNV");
5845 }
5846#ifdef VK_USE_PLATFORM_WIN32_KHR
5847 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5848 if (export_memory_win32_nv) {
5849 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5850 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5851 "VkExportMemoryWin32HandleInfoNV");
5852 }
5853#endif
5854 }
5855
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005856 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005857 VkBool32 capture_replay = false;
5858 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005859 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005860 if (vulkan_12_features) {
5861 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5862 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5863 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005864 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005865 if (bda_features) {
5866 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5867 buffer_device_address = bda_features->bufferDeviceAddress;
5868 }
5869 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005870 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005871 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005872 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005873 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005874 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005875 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005876 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005877 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005878 }
5879 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005880 }
5881 return skip;
5882}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005883
Jason Macnak192fa0e2019-07-26 15:07:16 -07005884bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005885 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005886 bool skip = false;
5887
5888 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5889 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5890 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005891 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005892 } else {
5893 uint32_t vertex_component_size = 0;
5894 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5895 vertex_component_size = 4;
5896 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5897 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5898 vertex_component_size = 2;
5899 }
5900 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005901 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005902 }
5903 }
5904
5905 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5906 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005907 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005908 } else {
5909 uint32_t index_element_size = 0;
5910 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5911 index_element_size = 4;
5912 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5913 index_element_size = 2;
5914 }
5915 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005916 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005917 }
5918 }
5919 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5920 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005921 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005922 }
5923 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005924 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005925 }
5926 }
5927
5928 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005929 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005930 }
5931
5932 return skip;
5933}
5934
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005935bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5936 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005937 bool skip = false;
5938
5939 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005940 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005941 }
5942 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005943 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005944 }
5945
5946 return skip;
5947}
5948
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005949bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5950 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005951 bool skip = false;
5952 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005953 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005954 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005955 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005956 }
5957 return skip;
5958}
5959
5960bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005961 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005962 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005963 bool skip = false;
5964 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005965 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5966 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5967 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005968 }
5969 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005970 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5971 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5972 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005973 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005974 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5975 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5976 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5977 }
Jason Macnak5c954952019-07-09 15:46:12 -07005978 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5979 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005980 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5981 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5982 "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 -07005983 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005984 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005985 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005986 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5987 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005988 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5989 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005990 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005991 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005992 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5993 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5994 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005995 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005996 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005997 uint64_t total_triangle_count = 0;
5998 for (uint32_t i = 0; i < info.geometryCount; i++) {
5999 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07006000
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006001 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07006002
Jason Macnak5c954952019-07-09 15:46:12 -07006003 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
6004 continue;
6005 }
6006 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
6007 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006008 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006009 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
6010 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
6011 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07006012 }
6013 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07006014 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
6015 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
6016 for (uint32_t i = 1; i < info.geometryCount; i++) {
6017 const VkGeometryNV &geometry = info.pGeometries[i];
6018 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006019 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006020 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
6021 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006022 "info.pGeometries[0].geometryType.",
6023 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07006024 }
6025 }
6026 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006027 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
6028 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
6029 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
6030 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
6031 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
6032 "or VK_GEOMETRY_TYPE_AABBS_NV.");
6033 }
6034 }
6035 skip |=
6036 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006037 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006038 return skip;
6039}
6040
Ricardo Garciaa4935972019-02-21 17:43:18 +01006041bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6042 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006043 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006044 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006045 if (pCreateInfo) {
6046 if ((pCreateInfo->compactedSize != 0) &&
6047 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006048 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6049 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6050 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6051 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006052 }
Jason Macnak5c954952019-07-09 15:46:12 -07006053
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006054 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006055 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006056 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006057 return skip;
6058}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006059
Jeff Bolz5c801d12019-10-09 10:38:45 -05006060bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6061 const VkAccelerationStructureInfoNV *pInfo,
6062 VkBuffer instanceData, VkDeviceSize instanceOffset,
6063 VkBool32 update, VkAccelerationStructureNV dst,
6064 VkAccelerationStructureNV src, VkBuffer scratch,
6065 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006066 bool skip = false;
6067
6068 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006069 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006070 }
6071
6072 return skip;
6073}
6074
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006075bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6076 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6077 VkAccelerationStructureKHR *pAccelerationStructure) const {
6078 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006079 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006080 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006081 if (!acceleration_structure_features ||
6082 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6083 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6084 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6085 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006086 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006087 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6088 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006089 (acceleration_structure_features &&
6090 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006091 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006092 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6093 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6094 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6095 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006096 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006097 if (pCreateInfo->deviceAddress &&
6098 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6099 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6100 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6101 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6102 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006103 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6104 (acceleration_structure_features &&
6105 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6106 skip |= LogError(
6107 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6108 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6109 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6110 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006111 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6112 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006113 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6114 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006115 }
sourav parmar83c31b12020-05-06 12:30:54 -07006116 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006117 return skip;
6118}
6119
Jason Macnak5c954952019-07-09 15:46:12 -07006120bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6121 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006122 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006123 bool skip = false;
6124 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006125 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6126 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006127 }
6128 return skip;
6129}
6130
sourav parmarcd5fb182020-07-17 12:58:44 -07006131bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6132 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6133 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6134 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006135 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006136 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006137 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006138 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006139 }
6140 return skip;
6141}
6142
Peter Chen85366392019-05-14 15:20:11 -04006143bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6144 uint32_t createInfoCount,
6145 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6146 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006147 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006148 bool skip = false;
6149
6150 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006151 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6152 std::stringstream msg;
6153 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6154 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6155 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006156 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006157 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006158 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006159 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6160 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6161 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6162 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006163 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006164
6165 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006166 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006167 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6168 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6169 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6170 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6171 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6172 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6173 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6174 }
6175 }
6176
sourav parmarf4a78252020-04-10 13:04:21 -07006177 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6178 skip |=
6179 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6180 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6181 }
6182 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6183 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6184 skip |=
6185 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6186 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6187 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6188 }
6189 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6190 if (pCreateInfos[i].basePipelineIndex != -1) {
6191 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6192 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6193 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6194 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6195 "and pCreateInfos->basePipelineIndex is not -1.");
6196 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006197 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006198 skip |=
6199 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6200 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6201 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6202 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6203 "that element.");
6204 }
sourav parmarf4a78252020-04-10 13:04:21 -07006205 }
6206 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006207 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006208 skip |=
6209 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6210 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6211 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6212 "commands pCreateInfos parameter.");
6213 }
6214 } else {
6215 if (pCreateInfos[i].basePipelineIndex != -1) {
6216 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6217 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6218 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6219 }
6220 }
6221 }
6222 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6223 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6224 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6225 }
6226 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6227 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6228 "vkCreateRayTracingPipelinesNV: flags must not include "
6229 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6230 }
6231 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6232 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6233 "vkCreateRayTracingPipelinesNV: flags must not include "
6234 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6235 }
6236 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6237 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6238 "vkCreateRayTracingPipelinesNV: flags must not include "
6239 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6240 }
6241 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6242 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6243 "vkCreateRayTracingPipelinesNV: flags must not include "
6244 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6245 }
6246 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6247 skip |= LogError(
6248 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6249 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6250 }
6251 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6252 skip |= LogError(
6253 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6254 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6255 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006256 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6257 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6258 "vkCreateRayTracingPipelinesNV: flags must not include "
6259 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6260 }
6261 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6262 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6263 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6264 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006265 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6266 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6267 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6268 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6269 }
Peter Chen85366392019-05-14 15:20:11 -04006270 }
6271
6272 return skip;
6273}
6274
sourav parmarcd5fb182020-07-17 12:58:44 -07006275bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6276 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6277 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006278 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006279 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006280 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6281 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6282 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006283 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006284 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006285 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6286 std::stringstream msg;
6287 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6288 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006289 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006290 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006291 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6292 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6293 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6294 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6295 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6296 }
6297 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6298 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6299 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6300 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6301 }
6302 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006303 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006304 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006305 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006306 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6307 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6308 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006309 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6310 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6311 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006312 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006313 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006314 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6315 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6316 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6317 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006318 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006319 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6320 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6321 }
6322 }
sourav parmarf4a78252020-04-10 13:04:21 -07006323 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006324 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6325 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006326 }
6327 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006328 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006329 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006330 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6331 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006332 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006333 }
6334 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6335 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6336 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006337 }
6338 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6339 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6340 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6341 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6342 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6343 skip |= LogError(
6344 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006345 "vkCreateRayTracingPipelinesKHR: If flags includes "
6346 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006347 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6348 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6349 "must not be VK_SHADER_UNUSED_KHR");
6350 }
6351 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6352 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6353 skip |= LogError(
6354 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006355 "vkCreateRayTracingPipelinesKHR: If flags includes "
6356 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006357 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6358 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6359 "element must not be VK_SHADER_UNUSED_KHR");
6360 }
6361 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006362 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6363 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6364 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6365 skip |= LogError(
6366 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6367 "vkCreateRayTracingPipelinesKHR: If "
6368 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6369 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6370 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6371 }
6372 }
sourav parmarf4a78252020-04-10 13:04:21 -07006373 }
6374 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6375 if (pCreateInfos[i].basePipelineIndex != -1) {
6376 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6377 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006378 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006379 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6380 "and pCreateInfos->basePipelineIndex is not -1.");
6381 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006382 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006383 skip |=
6384 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6385 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6386 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6387 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6388 "element.");
6389 }
sourav parmarf4a78252020-04-10 13:04:21 -07006390 }
6391 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006392 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006393 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006394 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006395 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6396 ") must be a valid into the calling"
6397 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006398 pCreateInfos[i].basePipelineIndex, createInfoCount);
6399 }
6400 } else {
6401 if (pCreateInfos[i].basePipelineIndex != -1) {
6402 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006403 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006404 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6405 }
6406 }
6407 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006408 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6409 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6410 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6411 "vkCreateRayTracingPipelinesKHR: If flags includes "
6412 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6413 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006414 }
6415 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6416 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6417 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6418 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6419 "pLibraryInfo and pLibraryInterface must be NULL.");
6420 }
6421 if (pCreateInfos[i].pLibraryInfo) {
6422 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6423 if (pCreateInfos[i].stageCount == 0) {
6424 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6425 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6426 "stageCount must not be 0.");
6427 }
6428 if (pCreateInfos[i].groupCount == 0) {
6429 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6430 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6431 "groupCount must not be 0.");
6432 }
6433 } else {
6434 if (pCreateInfos[i].pLibraryInterface == NULL) {
6435 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6436 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6437 "is greater than 0, its "
6438 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006439 }
6440 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006441 }
6442 if (pCreateInfos[i].pLibraryInterface) {
6443 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6444 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6445 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6446 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6447 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6448 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006449 }
6450 if (deferredOperation != VK_NULL_HANDLE) {
6451 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6452 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6453 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6454 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006455 }
6456 }
ziga-lunargdea76582021-09-17 14:38:08 +02006457 if (pCreateInfos[i].pDynamicState) {
6458 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6459 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6460 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6461 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6462 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6463 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6464 }
6465 }
6466 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006467 }
6468
6469 return skip;
6470}
6471
Mike Schuchardt21638df2019-03-16 10:52:02 -07006472#ifdef VK_USE_PLATFORM_WIN32_KHR
6473bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6474 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006475 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006476 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006477 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006478 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006479 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006480 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006481 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006482 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006483 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006484 skip |=
6485 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006486 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006487 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6488 skip |= validate_struct_type(
6489 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6490 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6491 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6492 if (pSurfaceInfo != NULL) {
6493 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6494 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6495 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6496
6497 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6498 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6499 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6500 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006501 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6502 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006503
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006504 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6505 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6506 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6507 "VK_GOOGLE_surfaceless_query is not enabled.");
6508 }
6509
Mike Schuchardt21638df2019-03-16 10:52:02 -07006510 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6511 }
6512 return skip;
6513}
6514#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006515
6516bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6517 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006518 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006519 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6520 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006521 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006522 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6523 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6524 }
6525 return skip;
6526}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006527
6528bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006529 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006530 bool skip = false;
6531
6532 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006533 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006534 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006535 }
6536
6537 return skip;
6538}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006539
6540bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006541 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006542 bool skip = false;
6543
6544 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006545 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6546 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006547 }
6548
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006549 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006550 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006551 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6552 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006553 }
6554
6555 return skip;
6556}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006557
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006558bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6559 uint32_t bindingCount, const VkBuffer *pBuffers,
6560 const VkDeviceSize *pOffsets) const {
6561 bool skip = false;
6562 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006563 skip |=
6564 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6565 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6566 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006567 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6568 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006569 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6570 ") must be less than "
6571 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006572 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6573 }
6574
Jeff Bolz165818a2020-05-08 11:19:03 -05006575 for (uint32_t i = 0; i < bindingCount; ++i) {
6576 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006577 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006578 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006579 skip |=
6580 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6581 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006582 } else {
6583 if (pOffsets[i] != 0) {
6584 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006585 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6586 "] is not 0",
6587 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006588 }
6589 }
6590 }
6591 }
6592
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006593 return skip;
6594}
6595
Mark Lobodzinski84988402019-09-11 15:27:30 -06006596bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006597 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006598 bool skip = false;
6599 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006600 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6601 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006602 }
6603 return skip;
6604}
6605
6606bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006607 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006608 bool skip = false;
6609 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006610 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6611 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006612 }
6613 return skip;
6614}
Petr Kraus3d720392019-11-13 02:52:39 +01006615
6616bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6617 VkSemaphore semaphore, VkFence fence,
6618 uint32_t *pImageIndex) const {
6619 bool skip = false;
6620
6621 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006622 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6623 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006624 }
6625
6626 return skip;
6627}
6628
6629bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6630 uint32_t *pImageIndex) const {
6631 bool skip = false;
6632
6633 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006634 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6635 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006636 }
6637
6638 return skip;
6639}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006640
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006641bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6642 uint32_t firstBinding, uint32_t bindingCount,
6643 const VkBuffer *pBuffers,
6644 const VkDeviceSize *pOffsets,
6645 const VkDeviceSize *pSizes) const {
6646 bool skip = false;
6647
6648 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6649 for (uint32_t i = 0; i < bindingCount; ++i) {
6650 if (pOffsets[i] & 3) {
6651 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6652 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6653 }
6654 }
6655
6656 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6657 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6658 "%s: The firstBinding(%" PRIu32
6659 ") index is greater than or equal to "
6660 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6661 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6662 }
6663
6664 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6665 skip |=
6666 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6667 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6668 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6669 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6670 }
6671
6672 for (uint32_t i = 0; i < bindingCount; ++i) {
6673 // pSizes is optional and may be nullptr.
6674 if (pSizes != nullptr) {
6675 if (pSizes[i] != VK_WHOLE_SIZE &&
6676 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6677 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6678 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6679 ") is not VK_WHOLE_SIZE and is greater than "
6680 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6681 cmd_name, i, pSizes[i]);
6682 }
6683 }
6684 }
6685
6686 return skip;
6687}
6688
6689bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6690 uint32_t firstCounterBuffer,
6691 uint32_t counterBufferCount,
6692 const VkBuffer *pCounterBuffers,
6693 const VkDeviceSize *pCounterBufferOffsets) const {
6694 bool skip = false;
6695
6696 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6697 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6698 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6699 "%s: The firstCounterBuffer(%" PRIu32
6700 ") index is greater than or equal to "
6701 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6702 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6703 }
6704
6705 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6706 skip |=
6707 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6708 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6709 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6710 cmd_name, firstCounterBuffer, counterBufferCount,
6711 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6712 }
6713
6714 return skip;
6715}
6716
6717bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6718 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6719 const VkBuffer *pCounterBuffers,
6720 const VkDeviceSize *pCounterBufferOffsets) const {
6721 bool skip = false;
6722
6723 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6724 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6725 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6726 "%s: The firstCounterBuffer(%" PRIu32
6727 ") index is greater than or equal to "
6728 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6729 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6730 }
6731
6732 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6733 skip |=
6734 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6735 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6736 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6737 cmd_name, firstCounterBuffer, counterBufferCount,
6738 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6739 }
6740
6741 return skip;
6742}
6743
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006744bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6745 uint32_t firstInstance, VkBuffer counterBuffer,
6746 VkDeviceSize counterBufferOffset,
6747 uint32_t counterOffset, uint32_t vertexStride) const {
6748 bool skip = false;
6749
6750 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006751 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6752 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6753 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6754 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006755 }
6756
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006757 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006758 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006759 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006760 }
6761
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006762 return skip;
6763}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006764
6765bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6766 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6767 const VkAllocationCallbacks *pAllocator,
6768 VkSamplerYcbcrConversion *pYcbcrConversion,
6769 const char *apiName) const {
6770 bool skip = false;
6771
6772 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006773 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006774 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006775 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006776 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6777 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006778 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006779 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006780 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006781
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006782#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006783 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006784 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006785#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006786 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006787#endif
6788
sfricke-samsung1a72f942020-07-25 12:09:18 -07006789 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006790
6791 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006792 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006793 const VkComponentMapping components = pCreateInfo->components;
6794 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6795 if (FormatIsXChromaSubsampled(format) == true) {
6796 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6797 skip |=
6798 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006799 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6800 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006801 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006802 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006803
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006804 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6805 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6806 skip |= LogError(
6807 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6808 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6809 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6810 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6811 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006812
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006813 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6814 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6815 skip |=
6816 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006817 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6818 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006819 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
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 ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6823 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6824 skip |=
6825 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006826 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6827 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006828 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006829 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006830
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006831 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006832 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6833 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6834 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006835 skip |=
6836 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006837 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6838 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006839 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6840 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006841 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006842 }
6843
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006844 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6845 // Checks same VU multiple ways in order to give a more useful error message
6846 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6847 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6848 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6849 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6850 skip |= LogError(
6851 device, vuid,
6852 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6853 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6854 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6855 string_VkComponentSwizzle(components.b));
6856 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006857
sfricke-samsunged028b02021-09-06 23:14:51 -07006858 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6859 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006860 // 3 = no [a]
6861 // 2 = no [b,a]
6862 // 1 = no [g,b,a]
6863 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006864 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006865
sfricke-samsunged028b02021-09-06 23:14:51 -07006866 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6867 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006868 skip |= LogError(device, vuid,
6869 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6870 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
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 < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006874 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6875 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
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_B "
6879 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6880 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6881 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006882 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006883 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6884 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6885 skip |= LogError(device, vuid,
6886 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6887 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6888 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6889 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6890 string_VkComponentSwizzle(components.b));
6891 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006892 }
6893 }
6894
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006895 return skip;
6896}
6897
6898bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6899 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6900 const VkAllocationCallbacks *pAllocator,
6901 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6902 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6903 "vkCreateSamplerYcbcrConversion");
6904}
6905
6906bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6907 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6908 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6909 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6910 "vkCreateSamplerYcbcrConversionKHR");
6911}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006912
6913bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6914 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6915 bool skip = false;
6916 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6917 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6918
6919 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006920 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6921 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6922 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6923 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6924 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006925 }
6926 return skip;
6927}
sourav parmara96ab1a2020-04-25 16:28:23 -07006928
6929bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006930 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006931 bool skip = false;
6932 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6933 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6934 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6935 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006936 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006937 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6938 skip |= LogError(
6939 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6940 "vkCopyAccelerationStructureToMemoryKHR: The "
6941 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6942 }
6943 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6944 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6945 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6946 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6947 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6948 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006949 return skip;
6950}
6951
6952bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6953 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6954 bool skip = false;
6955 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6956 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6957 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6958 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6959 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006960 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6961 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006962 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006963 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006964 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006965 return skip;
6966}
6967
6968bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6969 const char *api_name) const {
6970 bool skip = false;
6971 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6972 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6973 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6974 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6975 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6976 api_name);
6977 }
6978 return skip;
6979}
6980
6981bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006982 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006983 bool skip = false;
6984 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006985 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006986 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006987 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006988 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6989 "vkCopyAccelerationStructureKHR: The "
6990 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006991 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006992 return skip;
6993}
6994
6995bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6996 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6997 bool skip = false;
6998 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6999 return skip;
7000}
7001
7002bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06007003 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007004 bool skip = false;
7005 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007006 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07007007 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
7008 }
7009 return skip;
7010}
7011
7012bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007013 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07007014 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007015 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007016 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007017 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
7018 skip |= LogError(
7019 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
7020 "vkCopyMemoryToAccelerationStructureKHR: The "
7021 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007022 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007023 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
7024 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07007025 return skip;
7026}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06007027
sourav parmara96ab1a2020-04-25 16:28:23 -07007028bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
7029 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
7030 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07007031 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07007032 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
7033 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007034 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007035 pInfo->src.deviceAddress);
7036 }
sourav parmar83c31b12020-05-06 12:30:54 -07007037 return skip;
7038}
7039bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7040 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7041 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7042 bool skip = false;
7043 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7044 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007045 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7046 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7047 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7048 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7049 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7050 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7051 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7052 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7053 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7054 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7055 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7056 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7057 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7058 }
sourav parmar83c31b12020-05-06 12:30:54 -07007059 }
7060 return skip;
7061}
7062bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7063 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7064 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7065 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007066 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007067 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7068 skip |= LogError(
7069 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7070 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7071 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7072 }
sourav parmar83c31b12020-05-06 12:30:54 -07007073 if (dataSize < accelerationStructureCount * stride) {
7074 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7075 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007076 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007077 dataSize, accelerationStructureCount, stride);
7078 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007079
sourav parmar83c31b12020-05-06 12:30:54 -07007080 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7081 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007082 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7083 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7084 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7085 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7086 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7087 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7088 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7089 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7090 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7091 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7092 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7093 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7094 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7095 }
sourav parmar83c31b12020-05-06 12:30:54 -07007096 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007097
7098 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7099 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007100 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7101 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7102 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7103 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7104 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007105 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007106 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7107 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7108 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7109 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7110 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007111 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7112 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7113 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7114 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7115 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7116 stride);
7117 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7118 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7119 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7120 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7121 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7122 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007123 }
7124 }
sourav parmar83c31b12020-05-06 12:30:54 -07007125 return skip;
7126}
7127bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7128 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7129 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007130 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007131 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7132 skip |= LogError(
7133 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7134 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7135 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007136 }
7137 return skip;
7138}
7139
7140bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007141 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7142 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7143 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7144 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007145 uint32_t width, uint32_t height, uint32_t depth) const {
7146 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007147 // RayGen
7148 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7149 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7150 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007151 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007152 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7153 0) {
7154 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7155 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7156 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7157 }
7158 // Callable
7159 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7160 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7161 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7162 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007163 }
7164 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7165 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7166 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007167 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7168 }
7169 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7170 0) {
7171 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7172 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7173 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007174 }
7175 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007176 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7177 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7178 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7179 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007180 }
7181 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7182 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007183 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7184 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007185 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007186 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7187 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7188 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7189 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7190 }
sourav parmar83c31b12020-05-06 12:30:54 -07007191 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007192 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7193 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7194 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7195 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007196 }
7197 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7198 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7199 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007200 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7201 }
7202 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7203 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7204 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7205 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7206 }
7207 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007208 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007209 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7210 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7211 }
7212 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7213 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007214 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007215 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7216 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007217 }
7218
sourav parmarcd5fb182020-07-17 12:58:44 -07007219 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7220 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007221 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007222 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7223 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7224 }
7225
7226 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7227 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007228 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007229 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7230 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007231 }
7232 return skip;
7233}
7234
sourav parmarcd5fb182020-07-17 12:58:44 -07007235bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7236 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7237 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7238 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007239 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007240 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007241 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7242 skip |= LogError(
7243 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7244 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7245 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007246 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007247 // RayGen
7248 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7249 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7250 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007251 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007252 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7253 0) {
7254 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7255 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7256 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7257 }
7258 // Callabe
7259 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7260 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7261 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7262 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007263 }
7264 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7265 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007266 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7267 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7268 }
7269 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7270 0) {
7271 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7272 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7273 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007274 }
7275 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007276 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7277 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7278 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7279 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007280 }
7281 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7282 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007283 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7284 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007285 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007286 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7287 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7288 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7289 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7290 }
sourav parmar83c31b12020-05-06 12:30:54 -07007291 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007292 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7293 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7294 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7295 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007296 }
7297 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7298 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007299 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7300 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7301 }
7302 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7303 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7304 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7305 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007306 }
7307
sourav parmarcd5fb182020-07-17 12:58:44 -07007308 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7309 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7310 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007311 }
7312 return skip;
7313}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007314
7315bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7316 VkDeviceAddress indirectDeviceAddress) const {
7317 bool skip = false;
7318 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7319 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7320 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007321 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007322 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7323 "feature must be enabled.");
7324 }
7325
7326 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7327 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7328 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7329 }
7330 return skip;
7331}
7332
sourav parmar83c31b12020-05-06 12:30:54 -07007333bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7334 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7335 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7336 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7337 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7338 uint32_t width, uint32_t height, uint32_t depth) const {
7339 bool skip = false;
7340 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7341 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7342 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7343 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7344 }
7345 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7346 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7347 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7348 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7349 }
7350 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7351 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7352 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7353 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7354 }
7355
7356 // hitShader
7357 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7358 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7359 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7360 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7361 }
7362 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7363 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7364 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7365 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7366 }
7367 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7368 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7369 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7370 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7371 }
7372
7373 // missShader
7374 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7375 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7376 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7377 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7378 }
7379 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7380 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7381 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7382 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7383 }
7384 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7385 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7386 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7387 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7388 }
7389
7390 // raygenShader
7391 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7392 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7393 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007394 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7395 }
7396 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7397 skip |=
7398 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7399 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7400 }
7401 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7402 skip |=
7403 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7404 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7405 }
7406 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7407 skip |=
7408 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7409 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007410 }
7411 return skip;
7412}
7413
sourav parmar83c31b12020-05-06 12:30:54 -07007414bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007415 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7416 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007417 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007418 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7419 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007420 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7421 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007422 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007423 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7424 }
7425 return skip;
7426}
7427
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007428bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7429 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007430 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007431 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007432
7433 if (!physical_device_features.multiViewport) {
7434 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007435 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7436 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007437 viewportCount);
7438 }
7439 } else { // multiViewport enabled
7440 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007441 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7442 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007443 ") must "
7444 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007445 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007446 }
7447 }
7448
7449 if (pViewports) {
7450 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7451 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007452 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007453 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007454 }
7455 }
7456
7457 return skip;
7458}
7459
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007460bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7461 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007462 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007463 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7464 return skip;
7465}
7466
7467bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7468 const VkViewport *pViewports) const {
7469 bool skip = false;
7470 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7471 return skip;
7472}
7473
7474bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7475 const VkRect2D *pScissors, bool is_ext) const {
7476 bool skip = false;
7477 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007478
7479 if (!physical_device_features.multiViewport) {
7480 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007481 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7482 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007483 ") must "
7484 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007485 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007486 }
7487 } else { // multiViewport enabled
7488 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007489 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7490 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007491 ") must "
7492 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007493 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007494 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007495 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7496 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007497 ") must "
7498 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007499 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007500 }
7501 }
7502
7503 if (pScissors) {
7504 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7505 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7506
7507 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007508 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7509 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007510 }
7511
7512 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007513 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7514 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007515 }
7516
7517 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7518 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007519 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7520 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7521 "] will overflow int32_t.",
7522 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007523 }
7524
7525 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7526 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007527 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7528 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7529 "] will overflow int32_t.",
7530 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7531 }
7532 }
7533 }
7534
7535 return skip;
7536}
7537
7538bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7539 const VkRect2D *pScissors) const {
7540 bool skip = false;
7541 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7542 return skip;
7543}
7544
7545bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7546 const VkRect2D *pScissors) const {
7547 bool skip = false;
7548 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7549 return skip;
7550}
7551
7552bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7553 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7554 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7555 bool is_2ext) const {
7556 bool skip = false;
7557 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7558 if (firstBinding >= device_limits.maxVertexInputBindings) {
7559 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7560 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7561 firstBinding, device_limits.maxVertexInputBindings);
7562 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7563 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7564 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7565 ") must be less than "
7566 "maxVertexInputBindings (%" PRIu32 ")",
7567 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7568 }
7569
7570 for (uint32_t i = 0; i < bindingCount; ++i) {
7571 if (pBuffers[i] == VK_NULL_HANDLE) {
7572 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7573 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7574 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7575 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7576 } else {
7577 if (pOffsets[i] != 0) {
7578 skip |=
7579 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7580 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7581 }
7582 }
7583 }
7584 if (pStrides) {
7585 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7586 skip |=
7587 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7588 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7589 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007590 }
7591 }
7592 }
7593
7594 return skip;
7595}
7596
7597bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(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;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007602 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7603 return skip;
7604}
Piers Daniell39842ee2020-07-10 16:42:33 -06007605
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007606bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7607 uint32_t bindingCount, const VkBuffer *pBuffers,
7608 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7609 const VkDeviceSize *pStrides) const {
7610 bool skip = false;
7611 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007612 return skip;
7613}
sourav parmarcd5fb182020-07-17 12:58:44 -07007614
7615bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7616 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7617 bool skip = false;
7618 for (uint32_t i = 0; i < infoCount; ++i) {
7619 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7620 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7621 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7622 }
7623 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7624 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7625 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7626 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7627 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7628 api_name);
7629 }
7630 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7631 skip |=
7632 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7633 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7634 }
7635 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7636 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7637 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7638 }
7639 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7640 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7641 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7642 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7643 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7644 api_name);
7645 }
7646 if (pInfos[i].pGeometries) {
7647 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7648 skip |= validate_ranged_enum(
7649 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7650 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7651 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7652 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007653 skip |= validate_struct_type(
7654 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7655 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7656 &(pInfos[i].pGeometries[j].geometry.triangles),
7657 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7658 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7659 skip |= validate_struct_pnext(
7660 api_name,
7661 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7662 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7663 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7664 skip |=
7665 validate_ranged_enum(api_name,
7666 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7667 ParameterName::IndexVector{i, j}),
7668 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7669 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7670 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7671 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7672 &pInfos[i].pGeometries[j].geometry.triangles,
7673 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7674 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7675 skip |= validate_ranged_enum(
7676 api_name,
7677 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7678 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7679 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7680
7681 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7682 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7683 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7684 }
7685 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7686 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7687 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7688 skip |=
7689 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7690 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7691 api_name);
7692 }
7693 }
7694 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7695 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7696 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7697 &pInfos[i].pGeometries[j].geometry.instances,
7698 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7699 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7700 skip |= validate_struct_type(
7701 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7702 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7703 &(pInfos[i].pGeometries[j].geometry.instances),
7704 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7705 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7706 skip |= validate_struct_pnext(
7707 api_name,
7708 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7709 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7710 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7711
7712 skip |= validate_bool32(api_name,
7713 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7714 ParameterName::IndexVector{i, j}),
7715 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7716 }
7717 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7718 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7719 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7720 &pInfos[i].pGeometries[j].geometry.aabbs,
7721 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7722 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7723 skip |= validate_struct_type(
7724 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7725 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7726 &(pInfos[i].pGeometries[j].geometry.aabbs),
7727 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7728 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7729 skip |= validate_struct_pnext(
7730 api_name,
7731 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7732 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7733 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7734 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7735 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7736 "(%s):stride must be less than or equal to 2^32-1", api_name);
7737 }
7738 }
7739 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7740 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7741 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7742 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7743 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7744 api_name);
7745 }
7746 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7747 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7748 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7749 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7750 "of elements of"
7751 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7752 api_name);
7753 }
7754 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7755 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7756 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7757 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7758 api_name);
7759 }
7760 }
7761 }
7762 }
7763 if (pInfos[i].ppGeometries != NULL) {
7764 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7765 skip |= validate_ranged_enum(
7766 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7767 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7768 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7769 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007770 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7771 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7772 &pInfos[i].ppGeometries[j]->geometry.triangles,
7773 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7774 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7775 skip |= validate_struct_type(
7776 api_name,
7777 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7778 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7779 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7780 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7781 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7782 skip |= validate_struct_pnext(
7783 api_name,
7784 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7785 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7786 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7787 skip |= validate_ranged_enum(api_name,
7788 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7789 ParameterName::IndexVector{i, j}),
7790 "VkFormat", AllVkFormatEnums,
7791 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7792 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7793 skip |= validate_ranged_enum(api_name,
7794 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7795 ParameterName::IndexVector{i, j}),
7796 "VkIndexType", AllVkIndexTypeEnums,
7797 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7798 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7799 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7800 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7801 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7802 }
7803 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7804 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7805 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7806 skip |=
7807 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7808 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7809 api_name);
7810 }
7811 }
7812 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7813 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7814 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7815 &pInfos[i].ppGeometries[j]->geometry.instances,
7816 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7817 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7818 skip |= validate_struct_type(
7819 api_name,
7820 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7821 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7822 &(pInfos[i].ppGeometries[j]->geometry.instances),
7823 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7824 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7825 skip |= validate_struct_pnext(
7826 api_name,
7827 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7828 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7829 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7830 skip |= validate_bool32(api_name,
7831 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7832 ParameterName::IndexVector{i, j}),
7833 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7834 }
7835 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7836 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7837 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7838 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7839 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7840 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7841 skip |= validate_struct_type(
7842 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7843 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7844 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7845 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7846 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7847 skip |= validate_struct_pnext(
7848 api_name,
7849 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7850 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7851 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7852 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7853 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7854 "(%s):stride must be less than or equal to 2^32-1", api_name);
7855 }
7856 }
7857 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7858 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7859 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7860 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7861 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7862 api_name);
7863 }
7864 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7865 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7866 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7867 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7868 "of elements of"
7869 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7870 api_name);
7871 }
7872 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7873 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7874 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7875 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7876 api_name);
7877 }
7878 }
7879 }
7880 }
7881 }
7882 return skip;
7883}
7884bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7885 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7886 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7887 bool skip = false;
7888 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7889 for (uint32_t i = 0; i < infoCount; ++i) {
7890 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7891 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7892 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7893 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7894 "scratchData.deviceAddress member must be a multiple of "
7895 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7896 }
7897 for (uint32_t k = 0; k < infoCount; ++k) {
7898 if (i == k) continue;
7899 bool found = false;
7900 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007901 skip |=
7902 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7903 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7904 ") of pInfos must "
7905 "not be "
7906 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7907 ") of pInfos.",
7908 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007909 found = true;
7910 }
7911 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007912 skip |=
7913 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7914 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7915 ") of pInfos must "
7916 "not be "
7917 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7918 ") of pInfos.",
7919 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007920 found = true;
7921 }
7922 if (found) break;
7923 }
7924 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7925 if (pInfos[i].pGeometries) {
7926 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7927 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7928 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7929 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7930 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7931 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7932 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7933 }
7934 } else {
7935 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7936 skip |=
7937 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7938 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7939 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7940 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7941 }
7942 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007943 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007944 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7945 skip |= LogError(
7946 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7947 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7948 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7949 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007950 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7951 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007952 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7953 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7954 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7955 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7956 }
7957 }
7958 } else if (pInfos[i].ppGeometries) {
7959 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7960 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7961 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7962 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7963 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7964 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7965 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7966 }
7967 } else {
7968 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7969 skip |=
7970 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7971 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7972 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7973 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7974 }
7975 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007976 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007977 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7978 skip |= LogError(
7979 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7980 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7981 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7982 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007983 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7984 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007985 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7986 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7987 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7988 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7989 }
7990 }
7991 }
7992 }
7993 }
7994 return skip;
7995}
7996
7997bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7998 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7999 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
8000 const uint32_t *const *ppMaxPrimitiveCounts) const {
8001 bool skip = false;
8002 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
8003 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008004 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008005 if (!ray_tracing_acceleration_structure_features ||
8006 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
8007 skip |= LogError(
8008 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
8009 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
8010 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
8011 }
8012 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008013 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
8014 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
8015 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
8016 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
8017 "scratchData.deviceAddress member must be a multiple of "
8018 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
8019 }
8020 for (uint32_t k = 0; k < infoCount; ++k) {
8021 if (i == k) continue;
8022 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008023 skip |= LogError(
8024 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
8025 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
8026 ") "
8027 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
8028 "any other element [%" PRIu32 ") of pInfos.",
8029 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07008030 break;
8031 }
8032 }
8033 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
8034 if (pInfos[i].pGeometries) {
8035 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8036 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8037 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8038 skip |= LogError(
8039 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8040 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8041 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8042 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8043 }
8044 } else {
8045 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8046 skip |= LogError(
8047 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8048 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8049 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8050 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8051 }
8052 }
8053 }
8054 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8055 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8056 skip |= LogError(
8057 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8058 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8059 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8060 }
8061 }
8062 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8063 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8064 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8065 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8066 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8067 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8068 }
8069 }
8070 } else if (pInfos[i].ppGeometries) {
8071 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8072 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8073 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8074 skip |= LogError(
8075 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8076 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8077 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8078 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8079 }
8080 } else {
8081 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8082 skip |= LogError(
8083 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8084 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8085 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8086 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8087 }
8088 }
8089 }
8090 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8091 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8092 skip |= LogError(
8093 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8094 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8095 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8096 }
8097 }
8098 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8099 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8100 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8101 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8102 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8103 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8104 }
8105 }
8106 }
8107 }
8108 }
8109 return skip;
8110}
8111
8112bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8113 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8114 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8115 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8116 bool skip = false;
8117 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8118 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008119 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008120 if (!ray_tracing_acceleration_structure_features ||
8121 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8122 skip |=
8123 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8124 "vkBuildAccelerationStructuresKHR: The "
8125 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8126 }
8127 for (uint32_t i = 0; i < infoCount; ++i) {
8128 for (uint32_t j = 0; j < infoCount; ++j) {
8129 if (i == j) continue;
8130 bool found = false;
8131 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008132 skip |=
8133 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8134 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8135 ") of pInfos must "
8136 "not be "
8137 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8138 ") of pInfos.",
8139 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008140 found = true;
8141 }
8142 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008143 skip |=
8144 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8145 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8146 ") of pInfos must "
8147 "not be "
8148 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8149 ") of pInfos.",
8150 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008151 found = true;
8152 }
8153 if (found) break;
8154 }
8155 }
8156 return skip;
8157}
8158
8159bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8160 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8161 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8162 bool skip = false;
8163 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8164 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008165 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8166 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008167 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8168 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008169 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008170 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8171 }
8172 if (pBuildInfo != nullptr) {
8173 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8174 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8175 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8176 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8177 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008178 }
8179 return skip;
8180}
sfricke-samsungecafb192021-01-17 08:21:14 -08008181
Piers Daniellcb6d8032021-04-19 18:51:26 -06008182bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8183 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8184 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8185 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8186 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008187 const auto *vertex_attribute_divisor_features =
8188 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8189
Piers Daniellcb6d8032021-04-19 18:51:26 -06008190 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8191 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8192 skip |=
8193 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8194 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8195 }
8196
8197 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8198 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8199 skip |= LogError(
8200 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8201 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8202 }
8203
8204 // VUID-vkCmdSetVertexInputEXT-binding-04793
8205 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8206 bool binding_found = false;
8207 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8208 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8209 binding_found = true;
8210 break;
8211 }
8212 }
8213 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008214 skip |= LogError(
8215 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8216 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008217 }
8218 }
8219
8220 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8221 if (vertexBindingDescriptionCount > 1) {
8222 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8223 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8224 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8225 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8226 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008227 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8228 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008229 }
8230 }
8231 }
8232 }
8233
8234 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8235 if (vertexAttributeDescriptionCount > 1) {
8236 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8237 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8238 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8239 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8240 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008241 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8242 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008243 }
8244 }
8245 }
8246 }
8247
8248 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8249 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8250 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008251 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8252 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8253 "].binding is greater than maxVertexInputBindings",
8254 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008255 }
8256
8257 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8258 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008259 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8260 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8261 "].stride is greater than maxVertexInputBindingStride",
8262 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008263 }
8264
8265 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8266 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8267 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8268 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008269 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8270 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008271 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8272 binding);
8273 }
8274
8275 if (pVertexBindingDescriptions[binding].divisor > 1) {
8276 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8277 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8278 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008279 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8280 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008281 "vertexAttributeInstanceRateDivisor is not enabled",
8282 binding);
8283 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008284 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008285 if (pVertexBindingDescriptions[binding].divisor >
8286 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008287 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8288 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8289 "].divisor is greater than maxVertexAttribDivisor",
8290 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008291 }
8292
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008293 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008294 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008295 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8296 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8297 "].divisor is greater than 1 but inputRate "
8298 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8299 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008300 }
8301 }
8302 }
8303 }
8304
8305 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008306 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008307 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008308 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8309 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8310 "].location is greater than maxVertexInputAttributes",
8311 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008312 }
8313
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008314 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008315 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008316 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8317 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8318 "].binding is greater than maxVertexInputBindings",
8319 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008320 }
8321
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008322 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008323 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008324 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8325 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8326 "].offset is greater than maxVertexInputAttributeOffset",
8327 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008328 }
8329
8330 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8331 VkFormatProperties properties;
8332 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8333 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8334 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008335 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8336 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008337 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8338 attribute);
8339 }
8340 }
8341
8342 return skip;
8343}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008344
8345bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8346 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8347 const void *pValues) const {
8348 bool skip = false;
8349 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8350 // Check that offset + size don't exceed the max.
8351 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8352 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008353 skip |=
8354 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8355 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8356 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008357 }
8358 if (size > max_push_constants_size - offset) {
8359 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008360 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8361 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008362 offset, size, max_push_constants_size);
8363 }
8364
8365 // size needs to be non-zero and a multiple of 4.
8366 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008367 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8368 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008369 }
8370
8371 // offset needs to be a multiple of 4.
8372 if ((offset & 0x3) != 0) {
8373 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008374 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008375 }
8376 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008377}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008378
8379bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8380 uint32_t srcCacheCount,
8381 const VkPipelineCache *pSrcCaches) const {
8382 bool skip = false;
8383 if (pSrcCaches) {
8384 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8385 if (pSrcCaches[index0] == dstCache) {
8386 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8387 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8388 report_data->FormatHandle(dstCache).c_str());
8389 break;
8390 }
8391 }
8392 }
8393 return skip;
8394}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008395
8396bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8397 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8398 uint32_t rangeCount,
8399 const VkImageSubresourceRange *pRanges) const {
8400 bool skip = false;
8401 if (!pColor) {
8402 skip |=
8403 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8404 }
8405 return skip;
8406}
8407
8408bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8409 const VkRenderPassBeginInfo *const rp_begin) const {
8410 bool skip = false;
8411 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8412 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8413 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008414 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008415 func_name, rp_begin->clearValueCount);
8416 }
8417 return skip;
8418}
8419
8420bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8421 VkSubpassContents) const {
8422 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8423 return skip;
8424}
8425
8426bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8427 const VkRenderPassBeginInfo *pRenderPassBegin,
8428 const VkSubpassBeginInfo *) const {
8429 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8430 return skip;
8431}
8432
8433bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8434 const VkSubpassBeginInfo *) const {
8435 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8436 return skip;
8437}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008438
8439bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8440 uint32_t firstDiscardRectangle,
8441 uint32_t discardRectangleCount,
8442 const VkRect2D *pDiscardRectangles) const {
8443 bool skip = false;
8444
8445 if (pDiscardRectangles) {
8446 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8447 const int64_t x_sum =
8448 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8449 if (x_sum > std::numeric_limits<int32_t>::max()) {
8450 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8451 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8452 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8453 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8454 }
8455
8456 const int64_t y_sum =
8457 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8458 if (y_sum > std::numeric_limits<int32_t>::max()) {
8459 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8460 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8461 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8462 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8463 }
8464 }
8465 }
8466
8467 return skip;
8468}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008469
8470bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8471 uint32_t queryCount, size_t dataSize, void *pData,
8472 VkDeviceSize stride, VkQueryResultFlags flags) const {
8473 bool skip = false;
8474
8475 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8476 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8477 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8478 }
8479
8480 return skip;
8481}
ziga-lunargcf340c42021-08-19 00:13:38 +02008482
8483bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8484 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8485 bool skip = false;
8486
8487 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8488 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8489 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8490 ") is not a multiple of 4.",
8491 pConditionalRenderingBegin->offset);
8492 }
8493
8494 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008495}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008496
8497bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8498 VkSurfaceKHR surface,
8499 uint32_t *pSurfaceFormatCount,
8500 VkSurfaceFormatKHR *pSurfaceFormats) const {
8501 bool skip = false;
8502 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8503 skip |= LogError(
8504 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8505 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8506 }
8507 return skip;
8508}
8509
8510bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8511 VkSurfaceKHR surface,
8512 uint32_t *pPresentModeCount,
8513 VkPresentModeKHR *pPresentModes) const {
8514 bool skip = false;
8515 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8516 skip |= LogError(
8517 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8518 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8519 }
8520 return skip;
8521}
8522
8523bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8524 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8525 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8526 bool skip = false;
8527 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8528 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8529 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8530 "VK_GOOGLE_surfaceless_query is not enabled.");
8531 }
8532 return skip;
8533}
8534
8535bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8536 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8537 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8538 bool skip = false;
8539 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8540 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8541 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8542 "VK_GOOGLE_surfaceless_query is not enabled.");
8543 }
8544 return skip;
8545}
8546
8547#ifdef VK_USE_PLATFORM_WIN32_KHR
8548bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8549 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8550 VkPresentModeKHR *pPresentModes) const {
8551 bool skip = false;
8552 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8553 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8554 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8555 "VK_GOOGLE_surfaceless_query is not enabled.");
8556 }
8557 return skip;
8558}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008559
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008560#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008561
8562bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8563 const char *func_name) const {
8564 bool skip = false;
8565
8566 if (pInfo && pInfo->pCreateInfo) {
8567 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8568 if (image_swapchain_create_info) {
8569 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8570 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8571 }
sjfricke7f73fbd2022-05-27 06:33:36 +09008572 const auto *drm_format_modifier_create_info =
8573 LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pInfo->pCreateInfo);
8574 if (drm_format_modifier_create_info) {
Mike Schuchardt75a4db52022-06-02 14:01:11 -07008575 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirements-pCreateInfo-06776",
sjfricke7f73fbd2022-05-27 06:33:36 +09008576 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageDrmFormatModifierExplicitCreateInfoEXT.",
8577 func_name);
8578 }
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008579 }
8580
8581 return skip;
8582}
8583
8584bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8585 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8586 bool skip = false;
8587
8588 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8589
8590 return skip;
8591}
8592
8593bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8594 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8595 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8596 bool skip = false;
8597
8598 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8599
8600 return skip;
8601}