blob: ce9e003af5cbf3685ff05f0b2c3f50b25569c6b6 [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 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001289 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001290
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001291 return skip;
1292}
1293
Jeff Bolz99e3f632020-03-24 22:59:22 -05001294bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1295 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1296 bool skip = false;
1297
1298 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001299 // Validate feature set if using CUBE_ARRAY
1300 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1301 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1302 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1303 "enabling the imageCubeArray feature.");
1304 }
1305
Jeff Bolz99e3f632020-03-24 22:59:22 -05001306 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1307 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1308 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001309 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1310 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001311 pCreateInfo->subresourceRange.layerCount);
1312 }
1313 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001314 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1315 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1316 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1317 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001318 }
1319 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001320
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001321 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001322 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001323 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1324 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1325 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1326 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1327 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1328 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1329 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001330 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1331 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001332 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1333 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1334 "not an ASTC format.",
1335 string_VkFormat(pCreateInfo->format));
1336 }
1337 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001338
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001339 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001340 if (ycbcr_conversion != nullptr) {
1341 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1342 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1343 skip |= LogError(
1344 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1345 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1346 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1347 "r swizzle = %s\n"
1348 "g swizzle = %s\n"
1349 "b swizzle = %s\n"
1350 "a swizzle = %s\n",
1351 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1352 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1353 }
1354 }
1355 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001356 }
1357 return skip;
1358}
1359
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001360bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001361 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001362 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001363
1364 // Note: for numerical correctness
1365 // - float comparisons should expect NaN (comparison always false).
1366 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1367
1368 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001369 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001370 if (v1_f <= 0.0f) return true;
1371
1372 float intpart;
1373 const float fract = modff(v1_f, &intpart);
1374
1375 assert(std::numeric_limits<float>::radix == 2);
1376 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1377 if (intpart >= u32_max_plus1) return false;
1378
1379 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001380 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001381 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001382 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001383 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001384 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001385 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001386 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001387 };
1388
1389 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1390 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1391 return (v1_f <= v2_f);
1392 };
1393
1394 // width
1395 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001396 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001397
1398 if (!(viewport.width > 0.0f)) {
1399 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001400 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1401 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001402 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1403 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001404 skip |= LogError(object, "VUID-VkViewport-width-01771",
1405 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1406 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001407 }
1408
1409 // height
1410 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001411 const bool negative_height_enabled =
1412 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001413 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001414
1415 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1416 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001417 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1418 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001419 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1420 height_healthy = false;
1421
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001422 skip |= LogError(object, "VUID-VkViewport-height-01773",
1423 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1424 ").",
1425 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001426 }
1427
1428 // x
1429 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001430 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001431 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001432 skip |= LogError(object, "VUID-VkViewport-x-01774",
1433 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1434 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001435 }
1436
1437 // x + width
1438 if (x_healthy && width_healthy) {
1439 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001440 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001441 skip |= LogError(
1442 object, "VUID-VkViewport-x-01232",
1443 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1444 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1445 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001446 }
1447 }
1448
1449 // y
1450 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001451 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001452 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001453 skip |= LogError(object, "VUID-VkViewport-y-01775",
1454 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1455 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001456 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001457 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001458 skip |= LogError(object, "VUID-VkViewport-y-01776",
1459 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1460 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001461 }
1462
1463 // y + height
1464 if (y_healthy && height_healthy) {
1465 const float boundary = viewport.y + viewport.height;
1466
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001467 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001468 skip |= LogError(object, "VUID-VkViewport-y-01233",
1469 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1470 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1471 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001472 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001473 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001474 LogError(object, "VUID-VkViewport-y-01777",
1475 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1476 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1477 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001478 }
1479 }
1480
sfricke-samsungfd06d422021-01-22 02:17:21 -08001481 // 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 -07001482 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001483 // minDepth
1484 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001485 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001486 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001487 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1488 "[0.0, 1.0] range.",
1489 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001490 }
1491
1492 // maxDepth
1493 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001494 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001495 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001496 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1497 "[0.0, 1.0] range.",
1498 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001499 }
1500 }
1501
1502 return skip;
1503}
1504
Dave Houlton142c4cb2018-10-17 15:04:41 -06001505struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001506 VkShadingRatePaletteEntryNV shadingRate;
1507 uint32_t width;
1508 uint32_t height;
1509};
1510
1511// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001512static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001513 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1514 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1515 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1516 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1517 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1518 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001519};
1520
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001521bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001522 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001523
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001524 SampleOrderInfo *sample_order_info;
1525 uint32_t info_idx = 0;
1526 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1527 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1528 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001529 break;
1530 }
1531 }
1532
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001533 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001534 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1535 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1536 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001537 return skip;
1538 }
1539
Dave Houlton142c4cb2018-10-17 15:04:41 -06001540 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001541 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001542 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1543 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1544 ") must "
1545 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1546 "is set in framebufferNoAttachmentsSampleCounts.",
1547 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001548 }
1549
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001550 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001551 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1552 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1553 ") must "
1554 "be equal to the product of sampleCount (=%" PRIu32
1555 "), the fragment width for shadingRate "
1556 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001557 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001558 }
1559
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001560 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001561 skip |= LogError(
1562 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001563 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1564 ") must "
1565 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001566 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001567 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001568
1569 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001570 // the first width*height*sampleCount bits to all be set. Note: There is no
1571 // guarantee that 64 bits is enough, but practically it's unlikely for an
1572 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001573 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001574 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001575 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001576 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1577 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001578 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1579 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001580 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001581 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001582 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1583 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001584 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001585 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001586 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1587 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001588 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001589 uint32_t idx =
1590 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1591 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001592 }
1593
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001594 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1595 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001596 skip |= LogError(
1597 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001598 "The array pSampleLocations must contain exactly one entry for "
1599 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001600 }
1601
1602 return skip;
1603}
1604
sfricke-samsung51303fb2021-05-09 19:09:13 -07001605bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1606 const VkAllocationCallbacks *pAllocator,
1607 VkPipelineLayout *pPipelineLayout) const {
1608 bool skip = false;
1609 // Validate layout count against device physical limit
1610 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1611 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001612 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1613 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001614 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1615 }
1616
Nathaniel Cesariodb38b7a2022-03-10 22:16:51 -07001617 const bool has_independent_sets = (pCreateInfo->flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT) != 0;
1618 const bool graphics_pipeline_library = IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library);
1619 const char *const valid_dsl_vuid = (!graphics_pipeline_library)
1620 ? "VUID-VkPipelineLayoutCreateInfo-pSetLayouts-06561"
1621 : ((!has_independent_sets) ? "VUID-VkPipelineLayoutCreateInfo-flags-06562" : nullptr);
1622 if (valid_dsl_vuid) {
1623 for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
1624 if (!pCreateInfo->pSetLayouts[i]) {
1625 skip |=
1626 LogError(device, valid_dsl_vuid, "vkCreatePipelineLayout(): pSetLayouts[%" PRIu32 "] is VK_NULL_HANDLE.", i);
1627 }
1628 }
1629 }
1630
sfricke-samsung51303fb2021-05-09 19:09:13 -07001631 // Validate Push Constant ranges
1632 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1633 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1634 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1635 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1636 // Check that offset + size don't exceed the max.
1637 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1638 if (offset >= max_push_constants_size) {
1639 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001640 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1641 ") that exceeds this "
1642 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001643 i, offset, max_push_constants_size);
1644 }
1645 if (size > max_push_constants_size - offset) {
1646 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001647 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1648 ") and size (%" PRIu32
1649 ") "
1650 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001651 i, offset, size, max_push_constants_size);
1652 }
1653
1654 // size needs to be non-zero and a multiple of 4.
1655 if (size == 0) {
1656 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001657 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1658 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001659 i, size);
1660 }
1661 if (size & 0x3) {
1662 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001663 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1664 ") is not a multiple of 4.",
1665 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001666 }
1667
1668 // offset needs to be a multiple of 4.
1669 if ((offset & 0x3) != 0) {
1670 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001671 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1672 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001673 i, offset);
1674 }
1675 }
1676
1677 // 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.
1678 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1679 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1680 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001681 skip |=
1682 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1683 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001684 }
1685 }
1686 }
1687 return skip;
1688}
1689
ziga-lunargc6341372021-07-28 12:57:42 +02001690bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1691 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1692 bool skip = false;
1693
1694 const auto *required_subgroup_size_features =
1695 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1696
1697 if (required_subgroup_size_features) {
1698 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1699 skip |= LogError(
1700 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1701 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1702 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1703 func_name, msg, pCreateInfo->flags);
1704 }
1705 }
1706
1707 return skip;
1708}
1709
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001710bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1711 uint32_t createInfoCount,
1712 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1713 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001714 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001715 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001716
1717 if (pCreateInfos != nullptr) {
1718 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001719 bool has_dynamic_viewport = false;
1720 bool has_dynamic_scissor = false;
1721 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001722 bool has_dynamic_depth_bias = false;
1723 bool has_dynamic_blend_constant = false;
1724 bool has_dynamic_depth_bounds = false;
1725 bool has_dynamic_stencil_compare = false;
1726 bool has_dynamic_stencil_write = false;
1727 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001728 bool has_dynamic_viewport_w_scaling_nv = false;
1729 bool has_dynamic_discard_rectangle_ext = false;
1730 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001731 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001732 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001733 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001734 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001735 bool has_dynamic_cull_mode = false;
1736 bool has_dynamic_front_face = false;
1737 bool has_dynamic_primitive_topology = false;
1738 bool has_dynamic_viewport_with_count = false;
1739 bool has_dynamic_scissor_with_count = false;
1740 bool has_dynamic_vertex_input_binding_stride = false;
1741 bool has_dynamic_depth_test_enable = false;
1742 bool has_dynamic_depth_write_enable = false;
1743 bool has_dynamic_depth_compare_op = false;
1744 bool has_dynamic_depth_bounds_test_enable = false;
1745 bool has_dynamic_stencil_test_enable = false;
1746 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001747 bool has_patch_control_points = false;
1748 bool has_rasterizer_discard_enable = false;
1749 bool has_depth_bias_enable = false;
1750 bool has_logic_op = false;
1751 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001752 bool has_dynamic_vertex_input = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001753
1754 // Create a copy of create_info and set non-included sub-state to null
1755 auto create_info = pCreateInfos[i];
1756 const auto *graphics_lib_info = LvlFindInChain<VkGraphicsPipelineLibraryCreateInfoEXT>(create_info.pNext);
1757 if (graphics_lib_info) {
Nathaniel Cesariobcb79682022-03-31 21:13:52 -06001758 // TODO (ncesario) Remove this once GPU-AV and debug printf is supported with pipeline libraries
1759 if (enabled[gpu_validation]) {
1760 skip |=
1761 LogError(device, kVUIDUndefined, "GPU-AV with VK_EXT_graphics_pipeline_library is not currently supported");
1762 }
1763 if (enabled[gpu_validation]) {
1764 skip |= LogError(device, kVUIDUndefined,
1765 "Debug printf with VK_EXT_graphics_pipeline_library is not currently supported");
1766 }
1767
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001768 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT)) {
1769 create_info.pVertexInputState = nullptr;
1770 create_info.pInputAssemblyState = nullptr;
1771 }
1772 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT)) {
1773 create_info.pViewportState = nullptr;
1774 create_info.pRasterizationState = nullptr;
1775 create_info.pTessellationState = nullptr;
1776 }
1777 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT)) {
1778 create_info.pDepthStencilState = nullptr;
1779 }
1780 if (!(graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) {
1781 create_info.pColorBlendState = nullptr;
1782 }
1783 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1784 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1785 create_info.pMultisampleState = nullptr;
1786 }
1787 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1788 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT))) {
1789 create_info.layout = VK_NULL_HANDLE;
1790 }
1791 if (!(graphics_lib_info->flags & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT |
1792 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT |
1793 VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT))) {
1794 create_info.renderPass = VK_NULL_HANDLE;
1795 create_info.subpass = 0;
1796 }
1797 }
1798
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001799 if (!create_info.renderPass) {
1800 if (create_info.pColorBlendState && create_info.pMultisampleState) {
1801 // Pipeline has fragment outout state
1802 const auto rendering_struct = LvlFindInChain<VkPipelineRenderingCreateInfo>(create_info.pNext);
1803 if (rendering_struct) {
1804 if ((rendering_struct->depthAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1805 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1806 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1807 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06583");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001808
1809 if (!FormatHasDepth(rendering_struct->depthAttachmentFormat)) {
1810 skip |= LogError(
1811 device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06587",
1812 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1813 "]: VkPipelineRenderingCreateInfo::depthAttachmentFormat (%s) does not have a depth aspect.",
1814 i, string_VkFormat(rendering_struct->depthAttachmentFormat));
1815 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001816 }
1817
1818 if ((rendering_struct->stencilAttachmentFormat != VK_FORMAT_UNDEFINED)) {
1819 skip |= validate_ranged_enum("VkPipelineRenderingCreateInfo", "stencilAttachmentFormat", "VkFormat",
1820 AllVkFormatEnums, rendering_struct->stencilAttachmentFormat,
1821 "VUID-VkGraphicsPipelineCreateInfo-renderPass-06584");
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001822 if (!FormatHasStencil(rendering_struct->stencilAttachmentFormat)) {
Nathaniel Cesario1ba7ca52022-04-18 12:35:00 -06001823 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-renderPass-06588",
1824 "vkCreateGraphicsPipelines() pCreateInfos[%" PRIu32
1825 "]: VkPipelineRenderingCreateInfo::stencilAttachmentFormat (%s) does not have a "
1826 "stencil aspect.",
1827 i, string_VkFormat(rendering_struct->stencilAttachmentFormat));
Nathaniel Cesarioe77320e2022-04-11 17:32:33 -06001828 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001829 }
Nathaniel Cesario45efaac2022-04-11 17:04:33 -06001830
1831 if (rendering_struct->colorAttachmentCount != 0) {
1832 skip |= validate_ranged_enum_array(
1833 "VkPipelineRenderingCreateInfo", "VUID-VkGraphicsPipelineCreateInfo-renderPass-06579",
1834 "colorAttachmentCount", "pColorAttachmentFormats", "VkFormat", AllVkFormatEnums,
1835 rendering_struct->colorAttachmentCount, rendering_struct->pColorAttachmentFormats, true, true);
1836 }
Nathaniel Cesario72f29552022-03-24 05:11:11 -06001837 }
1838 }
1839 }
1840
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001841 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library)) {
1842 if (create_info.stageCount == 0) {
1843 skip |=
1844 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stageCount-06604",
1845 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "].stageCount is 0, but %s is not enabled", i,
1846 VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME);
1847 }
1848 // TODO while PRIu32 should probably be used instead of %i below, %i is necessary due to
1849 // ParameterName::IndexFormatSpecifier
1850 skip |= validate_struct_type_array(
1851 "vkCreateGraphicsPipelines", ParameterName("pCreateInfos[%i].stageCount", ParameterName::IndexVector{i}),
1852 ParameterName("pCreateInfos[%i].pStages", ParameterName::IndexVector{i}),
1853 "VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO", pCreateInfos[i].stageCount, pCreateInfos[i].pStages,
1854 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, true, true,
1855 "VUID-VkPipelineShaderStageCreateInfo-sType-sType", "VUID-VkGraphicsPipelineCreateInfo-pStages-06600",
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06001856 "VUID-VkGraphicsPipelineCreateInfo-pStages-06600");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001857 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1858 ParameterName("pCreateInfos[%i].pRasterizationState", ParameterName::IndexVector{i}),
1859 "VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO",
1860 pCreateInfos[i].pRasterizationState,
1861 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, true,
1862 "VUID-VkGraphicsPipelineCreateInfo-pRasterizationState-06601",
1863 "VUID-VkPipelineRasterizationStateCreateInfo-sType-sType");
Nathaniel Cesario617ffdc2022-03-11 17:02:45 -07001864 }
1865
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07001866 // TODO probably should check dynamic state from graphics libraries, at least when creating an "executable pipeline"
1867 if (create_info.pDynamicState != nullptr) {
1868 const auto &dynamic_state_info = *create_info.pDynamicState;
Petr Kraus299ba622017-11-24 03:09:03 +01001869 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1870 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001871 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1872 if (has_dynamic_viewport == true) {
1873 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1874 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001875 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001876 i);
1877 }
1878 has_dynamic_viewport = true;
1879 }
1880 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1881 if (has_dynamic_scissor == true) {
1882 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1883 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001884 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001885 i);
1886 }
1887 has_dynamic_scissor = true;
1888 }
1889 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1890 if (has_dynamic_line_width == true) {
1891 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1892 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001893 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001894 i);
1895 }
1896 has_dynamic_line_width = true;
1897 }
1898 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1899 if (has_dynamic_depth_bias == true) {
1900 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1901 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001902 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001903 i);
1904 }
1905 has_dynamic_depth_bias = true;
1906 }
1907 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1908 if (has_dynamic_blend_constant == true) {
1909 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1910 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001911 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001912 i);
1913 }
1914 has_dynamic_blend_constant = true;
1915 }
1916 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1917 if (has_dynamic_depth_bounds == true) {
1918 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1919 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001920 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001921 i);
1922 }
1923 has_dynamic_depth_bounds = true;
1924 }
1925 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1926 if (has_dynamic_stencil_compare == true) {
1927 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1928 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001929 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001930 i);
1931 }
1932 has_dynamic_stencil_compare = true;
1933 }
1934 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1935 if (has_dynamic_stencil_write == true) {
1936 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1937 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001938 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001939 i);
1940 }
1941 has_dynamic_stencil_write = true;
1942 }
1943 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1944 if (has_dynamic_stencil_reference == true) {
1945 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1946 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001947 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001948 i);
1949 }
1950 has_dynamic_stencil_reference = true;
1951 }
1952 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1953 if (has_dynamic_viewport_w_scaling_nv == true) {
1954 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1955 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001956 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001957 i);
1958 }
1959 has_dynamic_viewport_w_scaling_nv = true;
1960 }
1961 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1962 if (has_dynamic_discard_rectangle_ext == true) {
1963 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1964 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001965 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001966 i);
1967 }
1968 has_dynamic_discard_rectangle_ext = true;
1969 }
1970 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1971 if (has_dynamic_sample_locations_ext == true) {
1972 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1973 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001974 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001975 i);
1976 }
1977 has_dynamic_sample_locations_ext = true;
1978 }
1979 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1980 if (has_dynamic_exclusive_scissor_nv == true) {
1981 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1982 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001983 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001984 i);
1985 }
1986 has_dynamic_exclusive_scissor_nv = true;
1987 }
1988 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1989 if (has_dynamic_shading_rate_palette_nv == true) {
1990 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1991 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001992 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001993 i);
1994 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001995 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001996 }
1997 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1998 if (has_dynamic_viewport_course_sample_order_nv == true) {
1999 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2000 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002001 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002002 i);
2003 }
2004 has_dynamic_viewport_course_sample_order_nv = true;
2005 }
2006 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
2007 if (has_dynamic_line_stipple == true) {
2008 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2009 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002010 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07002011 i);
2012 }
2013 has_dynamic_line_stipple = true;
2014 }
Piers Daniell39842ee2020-07-10 16:42:33 -06002015 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
2016 if (has_dynamic_cull_mode) {
2017 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2018 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002019 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002020 i);
2021 }
2022 has_dynamic_cull_mode = true;
2023 }
2024 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
2025 if (has_dynamic_front_face) {
2026 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2027 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002028 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002029 i);
2030 }
2031 has_dynamic_front_face = true;
2032 }
2033 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
2034 if (has_dynamic_primitive_topology) {
2035 skip |= LogError(
2036 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2037 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002038 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002039 i);
2040 }
2041 has_dynamic_primitive_topology = true;
2042 }
2043 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
2044 if (has_dynamic_viewport_with_count) {
2045 skip |= LogError(
2046 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2047 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002048 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002049 i);
2050 }
2051 has_dynamic_viewport_with_count = true;
2052 }
2053 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
2054 if (has_dynamic_scissor_with_count) {
2055 skip |= LogError(
2056 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2057 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002058 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002059 i);
2060 }
2061 has_dynamic_scissor_with_count = true;
2062 }
2063 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
2064 if (has_dynamic_vertex_input_binding_stride) {
2065 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2066 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
2067 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002068 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002069 i);
2070 }
2071 has_dynamic_vertex_input_binding_stride = true;
2072 }
2073 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
2074 if (has_dynamic_depth_test_enable) {
2075 skip |= LogError(
2076 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2077 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002078 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002079 i);
2080 }
2081 has_dynamic_depth_test_enable = true;
2082 }
2083 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
2084 if (has_dynamic_depth_write_enable) {
2085 skip |= LogError(
2086 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2087 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002088 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002089 i);
2090 }
2091 has_dynamic_depth_write_enable = true;
2092 }
2093 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
2094 if (has_dynamic_depth_compare_op) {
2095 skip |=
2096 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2097 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002098 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002099 i);
2100 }
2101 has_dynamic_depth_compare_op = true;
2102 }
2103 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
2104 if (has_dynamic_depth_bounds_test_enable) {
2105 skip |= LogError(
2106 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2107 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002108 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002109 i);
2110 }
2111 has_dynamic_depth_bounds_test_enable = true;
2112 }
2113 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
2114 if (has_dynamic_stencil_test_enable) {
2115 skip |= LogError(
2116 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2117 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002118 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002119 i);
2120 }
2121 has_dynamic_stencil_test_enable = true;
2122 }
2123 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
2124 if (has_dynamic_stencil_op) {
2125 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2126 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002127 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06002128 i);
2129 }
2130 has_dynamic_stencil_op = true;
2131 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002132 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
2133 // Not allowed for graphics pipelines
2134 skip |= LogError(
2135 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
2136 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002137 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
2138 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08002139 i, state_index);
2140 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002141 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
2142 if (has_patch_control_points) {
2143 skip |= LogError(
2144 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2145 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002146 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002147 i);
2148 }
2149 has_patch_control_points = true;
2150 }
2151 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
2152 if (has_rasterizer_discard_enable) {
2153 skip |= LogError(
2154 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2155 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002156 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002157 i);
2158 }
2159 has_rasterizer_discard_enable = true;
2160 }
2161 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
2162 if (has_depth_bias_enable) {
2163 skip |= LogError(
2164 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2165 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002166 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002167 i);
2168 }
2169 has_depth_bias_enable = true;
2170 }
2171 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
2172 if (has_logic_op) {
2173 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2174 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002175 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002176 i);
2177 }
2178 has_logic_op = true;
2179 }
2180 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
2181 if (has_primitive_restart_enable) {
2182 skip |= LogError(
2183 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
2184 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002185 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002186 i);
2187 }
2188 has_primitive_restart_enable = true;
2189 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002190 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2191 if (has_dynamic_vertex_input) {
2192 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002193 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2194 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2195 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002196 }
2197 has_dynamic_vertex_input = true;
2198 }
Petr Kraus299ba622017-11-24 03:09:03 +01002199 }
2200 }
2201
sfricke-samsung3b944422021-01-23 02:15:19 -08002202 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2203 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2204 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002205 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2206 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002207 i);
2208 }
2209
2210 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2211 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2212 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002213 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002214 i);
2215 }
2216
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002217 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(create_info.pNext);
2218 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != create_info.stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002219 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pipelineStageCreationFeedbackCount-06594",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002220 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2221 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2222 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002223 i, feedback_struct->pipelineStageCreationFeedbackCount, create_info.stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002224 }
2225
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002226 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002227
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002228 // Collect active stages and other information
2229 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002230 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002231 bool has_eval = false;
2232 bool has_control = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002233 if (create_info.pStages != nullptr) {
2234 for (uint32_t stage_index = 0; stage_index < create_info.stageCount; ++stage_index) {
2235 active_shaders |= create_info.pStages[stage_index].stage;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002236
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002237 if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002238 has_control = true;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002239 } else if (create_info.pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002240 has_eval = true;
2241 }
2242
2243 skip |= validate_string(
2244 "vkCreateGraphicsPipelines",
2245 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06002246 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002247
2248 std::stringstream msg;
2249 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2250 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002251 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002252 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002253 }
2254
2255 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002256 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2257 skip |=
2258 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2259 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2260 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2261 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002262
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002263 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002264 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2265
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002266 skip |= validate_struct_pnext(
2267 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002268 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002269 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2270 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2271 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2272 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002273
2274 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002275 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002276 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2277 }
2278
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002279 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002280 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2281 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002282 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002283 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2284 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2285
2286 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002287 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002288 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002289
2290 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002291 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002292 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2293
2294 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2295 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002296 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002297 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2298
2299 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002300 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002301 }
2302
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002303 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2304 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002305
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002306 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002307 skip |=
2308 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2309 "vkCreateGraphicsPipelines: pararameter "
2310 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2311 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002312 }
2313
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002314 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002315 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002316 skip |=
2317 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2318 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2319 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2320 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2321 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002322 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2323 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002324 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002325 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2326 skip |=
2327 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2328 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002329 create_info.pVertexInputState->vertexBindingDescriptionCount,
2330 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002331 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2332
2333 skip |= validate_array(
2334 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2335 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2336 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2337 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2338
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002339 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002340 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002341 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002342 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002343 skip |= validate_ranged_enum(
2344 "vkCreateGraphicsPipelines",
2345 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2346 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002347 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002348 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2349 }
2350 }
2351
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002352 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002353 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002354 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002355 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002356 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002357 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002358 skip |= validate_ranged_enum(
2359 "vkCreateGraphicsPipelines",
2360 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2361 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002362 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002363 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002364 if (FormatIsDepthOrStencil(format)) {
2365 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2366 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2367 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2368 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002369 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2370 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002371 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2372 "alignment, replace with a color format.",
2373 i, vertex_attribute_description_index, string_VkFormat(format));
2374 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002375 }
2376 }
2377
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002378 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002379 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2380 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002381 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2382 ") is "
2383 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002384 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002385 }
2386
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002387 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002388 skip |=
2389 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2390 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002391 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2392 ") is "
2393 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002394 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002395 }
2396
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002397 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002398 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2399 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002400 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2401 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002402 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2403 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002404 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2405 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002406 "(%" PRIu32 ") is not distinct.",
2407 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002408 }
2409 vertex_bindings.insert(vertex_bind_desc.binding);
2410
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002411 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2413 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002414 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2415 "].binding (%" PRIu32
2416 ") is "
2417 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002418 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 }
2420
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002421 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002422 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2423 "vkCreateGraphicsPipelines: parameter "
2424 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2425 "].stride (%" PRIu32
2426 ") is greater "
2427 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2428 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002429 }
2430 }
2431
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002432 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002433 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2434 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002435 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2436 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002437 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2438 "vkCreateGraphicsPipelines: parameter "
2439 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2440 "].location (%" PRIu32 ") is not distinct.",
2441 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002442 }
2443 attribute_locations.insert(vertex_attrib_desc.location);
2444
2445 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2446 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002447 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2448 "vkCreateGraphicsPipelines: parameter "
2449 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2450 "].binding (%" PRIu32
2451 ") does not exist "
2452 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2453 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002454 }
2455
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002456 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002457 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2458 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002459 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2460 "].location (%" PRIu32
2461 ") is "
2462 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002463 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 }
2465
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002466 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002467 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2468 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002469 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2470 "].binding (%" PRIu32
2471 ") is "
2472 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002473 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002474 }
2475
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002476 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002477 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2478 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002479 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2480 "].offset (%" PRIu32
2481 ") is "
2482 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002483 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002484 }
2485 }
2486 }
2487
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002488 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2489 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002490 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002491 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002492 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2493 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002494 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002495 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002496 i, i);
2497 } else {
2498 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2499 skip |= validate_struct_pnext(
2500 "vkCreateGraphicsPipelines",
2501 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002502 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002503 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2504 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002505
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002506 skip |= validate_reserved_flags(
2507 "vkCreateGraphicsPipelines",
2508 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002509 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002510
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002511 if (create_info.pTessellationState->patchControlPoints == 0 ||
2512 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2513 skip |=
2514 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2515 "vkCreateGraphicsPipelines: invalid parameter "
2516 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2517 ". patchControlPoints "
2518 "should be >0 and <=%" PRIu32 ".",
2519 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002520 }
2521 }
2522 }
2523
2524 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002525 if ((create_info.pRasterizationState != nullptr) &&
2526 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2527 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002528 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2529 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2530 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2531 "].pViewportState (=NULL) is not a valid pointer.",
2532 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002533 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002534 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002535
2536 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002537 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2538 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2539 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2540 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002541 }
2542
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002543 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002544 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002545 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2546 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002547 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2548 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002549 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002550 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002551 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002552 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002553 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002554 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002555 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002556 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002557 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002558 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002559 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002560 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002561
2562 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002563 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002564 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002565 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002567 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002568 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002569 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002570 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002571 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002572 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2573 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002574 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002575 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2576 const auto depth_clip_control_struct =
2577 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002578
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002579 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002580 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002581 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2582 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2583 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2584 ") is not 1.",
2585 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002586 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002587
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002588 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2590 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2591 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2592 ") is not 1.",
2593 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002595
Dave Houlton142c4cb2018-10-17 15:04:41 -06002596 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2597 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002598 skip |= LogError(
2599 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2600 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2601 "disabled, but pCreateInfos[%" PRIu32
2602 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2603 ") is not 1.",
2604 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002605 }
2606
Jeff Bolz9af91c52018-09-01 21:53:57 -05002607 if (shading_rate_image_struct &&
2608 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002609 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2610 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2611 "disabled, but pCreateInfos[%" PRIu32
2612 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2613 ") is neither 0 nor 1.",
2614 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002615 }
2616
Petr Krausa6103552017-11-16 21:21:58 +01002617 } else { // multiViewport enabled
2618 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002619 if (!has_dynamic_viewport_with_count) {
2620 skip |= LogError(
2621 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2622 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2623 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002624 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002625 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2626 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2627 "].pViewportState->viewportCount (=%" PRIu32
2628 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2629 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002630 } else if (has_dynamic_viewport_with_count) {
2631 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2632 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2633 "].pViewportState->viewportCount (=%" PRIu32
2634 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2635 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 }
Petr Krausa6103552017-11-16 21:21:58 +01002637
2638 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002639 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002640 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2641 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2642 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002643 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002644 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002645 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2646 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002647 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002648 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2649 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2650 "].pViewportState->scissorCount (=%" PRIu32
2651 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2652 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002653 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002654 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2655 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2656 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2657 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002658 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2659 "].pViewportState->scissorCount (=%" PRIu32
2660 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2661 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662 }
2663 }
2664
ziga-lunarg845883b2021-07-14 15:05:00 +02002665 if (!has_dynamic_scissor && viewport_state.pScissors) {
2666 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2667 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002668
2669 if (scissor.offset.x < 0) {
2670 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2671 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2672 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2673 scissor.offset.x, i, scissor_i);
2674 }
2675
2676 if (scissor.offset.y < 0) {
2677 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2678 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2679 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2680 scissor.offset.y, i, scissor_i);
2681 }
2682
ziga-lunarg845883b2021-07-14 15:05:00 +02002683 const int64_t x_sum =
2684 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2685 if (x_sum > std::numeric_limits<int32_t>::max()) {
2686 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2687 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2688 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2689 "] will overflow int32_t.",
2690 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2691 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002692
ziga-lunarg845883b2021-07-14 15:05:00 +02002693 const int64_t y_sum =
2694 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2695 if (y_sum > std::numeric_limits<int32_t>::max()) {
2696 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2697 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2698 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2699 "] will overflow int32_t.",
2700 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2701 }
2702 }
2703 }
2704
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002705 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002706 skip |=
2707 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2708 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2709 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2710 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002711 }
2712
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002713 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002714 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2715 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2716 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2717 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2718 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002719 }
2720
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002721 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2722 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2723 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2724 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2725 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2726 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2727 skip |= LogError(
2728 device, vuid,
2729 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2730 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2731 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2732 }
Petr Krausa6103552017-11-16 21:21:58 +01002733 }
2734
Dave Houlton142c4cb2018-10-17 15:04:41 -06002735 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002736 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002737 skip |=
2738 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2739 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2740 ") must be zero or identical to pCreateInfos[%" PRIu32
2741 "].pViewportState->viewportCount (=%" PRIu32 ").",
2742 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002743 }
2744
Dave Houlton142c4cb2018-10-17 15:04:41 -06002745 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002746 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002747 skip |= LogError(
2748 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002749 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2750 "] "
2751 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2752 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2753 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002754 }
2755
Petr Krausa6103552017-11-16 21:21:58 +01002756 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002757 skip |= LogError(
2758 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002759 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2760 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002761 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2762 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002763 }
2764
2765 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002766 skip |= LogError(
2767 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002768 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2769 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002770 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2771 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002772 }
2773
Jeff Bolz3e71f782018-08-29 23:15:45 -05002774 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002775 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2776 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2777 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002778 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002779 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2780 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2781 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2782 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002783 }
2784
Jeff Bolz9af91c52018-09-01 21:53:57 -05002785 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002786 shading_rate_image_struct->viewportCount > 0 &&
2787 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002788 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002789 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002790 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002791 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2792 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002793 i, i);
2794 }
2795
Chris Mayer328d8212018-12-11 14:16:18 +01002796 if (vp_swizzle_struct) {
2797 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002798 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2799 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2800 " does "
2801 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2802 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002803 }
2804 }
2805
Petr Krausb3fcdb42018-01-09 22:09:09 +01002806 // validate the VkViewports
2807 if (!has_dynamic_viewport && viewport_state.pViewports) {
2808 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2809 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002810 const char *fn_name = "vkCreateGraphicsPipelines";
2811 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2812 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2813 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002814 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002815 }
2816 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002817
sfricke-samsung45996a42021-09-16 13:45:27 -07002818 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002819 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2820 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2821 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2822 "VK_NV_clip_space_w_scaling extension is not enabled.",
2823 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002824 }
2825
sfricke-samsung45996a42021-09-16 13:45:27 -07002826 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002827 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2828 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2829 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2830 "VK_EXT_discard_rectangles extension is not enabled.",
2831 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002832 }
2833
sfricke-samsung45996a42021-09-16 13:45:27 -07002834 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002835 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2836 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2837 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2838 "VK_EXT_sample_locations extension is not enabled.",
2839 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002840 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002841
sfricke-samsung45996a42021-09-16 13:45:27 -07002842 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002843 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2844 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2845 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2846 "VK_NV_scissor_exclusive extension is not enabled.",
2847 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002848 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002849
2850 if (coarse_sample_order_struct &&
2851 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2852 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002853 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2854 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2855 "] "
2856 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2857 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2858 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002859 }
2860
2861 if (coarse_sample_order_struct) {
2862 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002863 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002864 }
2865 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002866
2867 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2868 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2870 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2871 "] "
2872 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2873 ") "
2874 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2875 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002876 }
2877 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002878 skip |= LogError(
2879 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002880 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2881 "] "
2882 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2883 i);
2884 }
2885 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002886
2887 if (depth_clip_control_struct) {
2888 const auto *depth_clip_control_features =
2889 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2890 const bool enabled_depth_clip_control =
2891 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2892 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2893 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2894 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2895 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2896 "depthClipControl feature is not enabled. ",
2897 i);
2898 }
2899 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900 }
2901
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002902 const bool is_frag_out_graphics_lib =
2903 graphics_lib_info &&
2904 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002905 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002907 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2908 "].pRasterizationState->rasterizerDiscardEnable "
2909 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002910 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002911 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002912 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002913 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002914 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2915 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002916 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002917 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002918 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002920 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002921 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002922 skip |= validate_struct_pnext(
2923 "vkCreateGraphicsPipelines",
2924 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002925 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002926 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2927 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002928
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002929 skip |= validate_reserved_flags(
2930 "vkCreateGraphicsPipelines",
2931 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002932 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002933
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002934 skip |= validate_bool32(
2935 "vkCreateGraphicsPipelines",
2936 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002937 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002939 skip |= validate_array(
2940 "vkCreateGraphicsPipelines",
2941 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2942 ParameterName::IndexVector{i}),
2943 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002944 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2945 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002946
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002947 skip |= validate_flags("vkCreateGraphicsPipelines",
2948 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2949 ParameterName::IndexVector{i}),
2950 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002951 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002952 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002954 skip |= validate_bool32("vkCreateGraphicsPipelines",
2955 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2956 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002957 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002959 skip |= validate_bool32(
2960 "vkCreateGraphicsPipelines",
2961 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002962 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002963
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002964 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002965 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
2966 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2967 "].pMultisampleState->sType must be "
2968 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002969 i);
John Zulauf7acac592017-11-06 11:15:53 -07002970 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002971 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002972 if (!physical_device_features.sampleRateShading) {
2973 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2974 "vkCreateGraphicsPipelines(): parameter "
2975 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
2976 i);
2977 }
2978 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2979 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002980 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002981 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002982
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002983 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2984 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2985 "].pMultisampleState->minSampleShading.",
2986 i);
2987 }
John Zulauf7acac592017-11-06 11:15:53 -07002988 }
2989 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002990
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002991 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002992 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002993
2994 if (line_state) {
2995 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2996 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002997 if (create_info.pMultisampleState->alphaToCoverageEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002998 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002999 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3000 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003001 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003002 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003003 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003004 if (create_info.pMultisampleState->alphaToOneEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003005 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003006 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3007 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003008 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003009 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003010 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003011 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003012 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003013 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3014 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003015 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003016 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003017 }
3018 }
3019 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3020 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3021 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003022 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003023 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3024 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003025 "range [1,256].",
3026 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003027 }
3028 }
3029 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003030 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003031 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3032 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003033 skip |=
3034 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003035 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3036 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003037 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3038 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003039 }
3040 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3041 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003042 skip |=
3043 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003044 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3045 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003046 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3047 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003048 }
3049 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3050 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003051 skip |=
3052 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003053 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3054 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003055 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3056 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003057 }
3058 if (line_state->stippledLineEnable) {
3059 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3060 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003061 skip |=
3062 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003063 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3064 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003065 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3066 "stippledRectangularLines feature.",
3067 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003068 }
3069 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3070 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003071 skip |=
3072 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003073 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3074 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003075 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3076 "stippledBresenhamLines feature.",
3077 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003078 }
3079 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3080 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003081 skip |=
3082 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003083 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3084 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003085 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3086 "stippledSmoothLines feature.",
3087 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003088 }
3089 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003090 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003091 skip |=
3092 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003093 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3094 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003095 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3096 "stippledRectangularLines and strictLines features.",
3097 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003098 }
3099 }
3100 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003101 }
3102
Petr Krause91f7a12017-12-14 20:57:36 +01003103 bool uses_color_attachment = false;
3104 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003105 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003106 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003107 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003108 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003109 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003110 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003111 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003112 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003113 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003114 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003115 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003116 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003117 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003118 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003119 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003120 }
3121
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003122 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003124 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003125 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003126 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003127 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128
Mike Schuchardt00e81452021-11-29 11:11:20 -08003129 skip |=
3130 validate_flags("vkCreateGraphicsPipelines",
3131 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3132 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003133 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003134 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003135
3136 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003137 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003138 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003139 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003140
3141 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003142 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003143 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003144 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003145
3146 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003147 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003149 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003150 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003151
3152 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003153 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003154 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003155 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003156
3157 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003158 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003159 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003160 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161
3162 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003163 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003164 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003165 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003166 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003167
3168 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003169 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003171 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003172 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003173
3174 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003175 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003177 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003178 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003179
3180 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003181 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003183 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003184 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003185
3186 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003187 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003188 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003189 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003190 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191
3192 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003193 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003194 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003195 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003196 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003197
3198 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003199 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003200 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003201 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003202 "VUID-VkStencilOpState-depthFailOp-parameter");
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->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003207 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003208 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003210 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003211 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003212 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3213 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003214 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3215 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003216 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003217
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003218 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003219 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3220 const auto *rasterization_order_attachment_access_feature =
3221 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3222 const bool rasterization_order_depth_attachment_access_feature_enabled =
3223 rasterization_order_attachment_access_feature &&
3224 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3225 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3226 skip |= LogError(
3227 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3228 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3229 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3230 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003231 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003232 }
3233
3234 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3235 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003236 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003237 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3238 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003239 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003240 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3241 }
3242 }
3243
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003244 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003245 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3246 const auto *rasterization_order_attachment_access_feature =
3247 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3248 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3249 rasterization_order_attachment_access_feature &&
3250 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3251 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3252 skip |= LogError(
3253 device,
3254 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3255 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3256 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3257 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003258 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003259 }
3260
3261 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3262 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003263 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003264 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3265 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003266 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003267 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3268 }
3269 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003270 }
3271
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003272 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003273 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3274 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003275
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003276 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3277 skip |=
3278 validate_struct_type("vkCreateGraphicsPipelines",
3279 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3280 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3281 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3282 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003283
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003284 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003285 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003286 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003287 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3288 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003289 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003290 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3291 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003292
Mike Schuchardt00e81452021-11-29 11:11:20 -08003293 skip |= validate_flags("vkCreateGraphicsPipelines",
3294 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3295 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003296 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003297 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003299 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003300 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3301 const auto *rasterization_order_attachment_access_feature =
3302 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3303 const bool rasterization_order_color_attachment_access_feature_enabled =
3304 rasterization_order_attachment_access_feature &&
3305 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3306
3307 if (!rasterization_order_color_attachment_access_feature_enabled) {
3308 skip |= LogError(
3309 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3310 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3311 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3312 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003313 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003314 }
3315
3316 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003317 skip |=
3318 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3319 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3320 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3321 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3322 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003323 }
3324 }
3325
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003326 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003327 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003328 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003329 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003330
3331 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003332 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3334 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003335 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3336 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003337
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003338 if (create_info.pColorBlendState->pAttachments != NULL) {
3339 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003340 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003341 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003342 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003343 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003344 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003345
3346 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003347 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003348 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003349 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003350 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003351 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003352 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003353
3354 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003355 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003356 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003357 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003358 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003359 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003360 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003361
3362 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003363 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003364 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003365 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003367 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003368 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003369
3370 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003371 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003372 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003373 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003374 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003375 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003376 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003377
3378 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003379 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003380 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003381 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003383 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003384 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003385
3386 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003387 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003388 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003389 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003390 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003391 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003392 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003393
3394 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003395 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003396 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003397 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003398 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003399 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003400 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003401
3402 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3403 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003404 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003405 case VK_BLEND_OP_ZERO_EXT:
3406 case VK_BLEND_OP_SRC_EXT:
3407 case VK_BLEND_OP_DST_EXT:
3408 case VK_BLEND_OP_SRC_OVER_EXT:
3409 case VK_BLEND_OP_DST_OVER_EXT:
3410 case VK_BLEND_OP_SRC_IN_EXT:
3411 case VK_BLEND_OP_DST_IN_EXT:
3412 case VK_BLEND_OP_SRC_OUT_EXT:
3413 case VK_BLEND_OP_DST_OUT_EXT:
3414 case VK_BLEND_OP_SRC_ATOP_EXT:
3415 case VK_BLEND_OP_DST_ATOP_EXT:
3416 case VK_BLEND_OP_XOR_EXT:
3417 case VK_BLEND_OP_INVERT_EXT:
3418 case VK_BLEND_OP_INVERT_RGB_EXT:
3419 case VK_BLEND_OP_LINEARDODGE_EXT:
3420 case VK_BLEND_OP_LINEARBURN_EXT:
3421 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3422 case VK_BLEND_OP_LINEARLIGHT_EXT:
3423 case VK_BLEND_OP_PINLIGHT_EXT:
3424 case VK_BLEND_OP_HARDMIX_EXT:
3425 case VK_BLEND_OP_PLUS_EXT:
3426 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3427 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3428 case VK_BLEND_OP_PLUS_DARKER_EXT:
3429 case VK_BLEND_OP_MINUS_EXT:
3430 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3431 case VK_BLEND_OP_CONTRAST_EXT:
3432 case VK_BLEND_OP_INVERT_OVG_EXT:
3433 case VK_BLEND_OP_RED_EXT:
3434 case VK_BLEND_OP_GREEN_EXT:
3435 case VK_BLEND_OP_BLUE_EXT:
3436 invalid = true;
3437 break;
3438 default:
3439 break;
3440 }
3441 if (invalid) {
3442 skip |= LogError(
3443 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3444 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3445 "].pColorBlendState->pAttachments[%" PRIu32
3446 "].colorBlendOp (%s) is not valid when "
3447 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3448 "VK_FALSE",
3449 i, attachment_index,
3450 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003451 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003452 }
3453 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003454 }
3455 }
3456
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003457 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003458 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003459 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3460 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003461 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3462 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003463 }
3464
3465 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003466 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003467 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003468 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003469 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003470 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003471 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003472 }
3473 }
3474 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003475
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003476 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003477 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003478 if (create_info.basePipelineIndex != -1) {
3479 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003480 skip |=
3481 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003482 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3483 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003484 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003485 "and pCreateInfos->basePipelineIndex is not -1.",
3486 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003487 }
3488 }
3489
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003490 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3491 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003492 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003493 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3494 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003495 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003496 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3497 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003498 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003499 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003500 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003501 skip |=
3502 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003503 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3504 ") must be a valid"
3505 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003506 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003507 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003508 }
3509 }
3510
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003511 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003512 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003513 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003514 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003515 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3516 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3517 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3518 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003519 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003520 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003521 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003522 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003523 "pCreateInfos[%" PRIu32
3524 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003525 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3526 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003527 }
3528 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003529 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3530 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003531 (physical_device_features.fillModeNonSolid == false)) {
3532 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003533 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3534 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003535 "pCreateInfos[%" PRIu32
3536 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003537 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3538 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003539 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540 }
Petr Kraus299ba622017-11-24 03:09:03 +01003541
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003542 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003543 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003544 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3545 "The line width state is static (pCreateInfos[%" PRIu32
3546 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3547 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3548 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003549 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003550 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003551 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003552
3553 // Validate no flags not allowed are used
3554 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003555 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003556 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3557 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003558 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3559 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003560 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003561 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3562 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003563 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003564 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3565 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003566 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3567 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003568 }
3569 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3570 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003571 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3572 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003573 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3574 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003575 }
3576 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3577 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003578 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3579 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003580 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3581 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003582 }
3583 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3584 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003585 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3586 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003587 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3588 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003589 }
3590 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3591 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003592 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3593 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003594 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3595 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003596 }
3597 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3598 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003599 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3600 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003601 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3602 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003603 }
3604 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3605 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003606 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3607 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003608 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3609 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003610 }
3611 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3612 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
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_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3616 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003617 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003618 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3619 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3620 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3621 "]->flags (0x%x) must not include "
3622 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3623 i, flags);
3624 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003625 }
3626 }
3627
3628 return skip;
3629}
3630
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003631bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3632 uint32_t createInfoCount,
3633 const VkComputePipelineCreateInfo *pCreateInfos,
3634 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003635 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003636 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003637 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003638 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003640 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003641 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003642 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3643 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003644 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003645 skip |= LogError(
3646 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3647 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3648 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3649 feedback_count, i);
3650 }
Peter Chen85366392019-05-14 15:20:11 -04003651 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003652
3653 // Make sure compute stage is selected
3654 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003655 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003656 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3657 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003658 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003659 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003660
sfricke-samsungeb549012021-04-16 01:25:51 -07003661 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3662 // Validate no flags not allowed are used
3663 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003664 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3665 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3666 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3667 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003668 }
3669 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3670 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003671 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3672 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003673 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3674 i, flags);
3675 }
3676 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3677 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003678 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3679 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003680 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3681 i, flags);
3682 }
3683 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3684 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003685 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3686 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003687 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3688 i, flags);
3689 }
3690 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3691 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003692 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3693 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003694 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3695 i, flags);
3696 }
3697 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3698 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003699 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3700 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003701 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3702 i, flags);
3703 }
3704 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3705 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003706 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3707 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003708 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3709 i, flags);
3710 }
3711 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3712 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
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_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3716 i, flags);
3717 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003718 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3719 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003720 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3721 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003722 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3723 i, flags);
3724 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003725 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3726 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
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_INDIRECT_BINDABLE_BIT_NV.",
3730 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003731 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003732 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3733 if (pCreateInfos[i].basePipelineIndex != -1) {
3734 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3735 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3736 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3737 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3738 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3739 i);
3740 }
3741 }
3742
3743 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3744 if (pCreateInfos[i].basePipelineIndex != -1) {
3745 skip |= LogError(
3746 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3747 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3748 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3749 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3750 i);
3751 }
3752 } else {
3753 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3754 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3755 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3756 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3757 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3758 }
3759 }
3760 }
ziga-lunargc6341372021-07-28 12:57:42 +02003761
3762 std::stringstream msg;
3763 msg << "pCreateInfos[%" << i << "].stage";
3764 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003765 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003766 return skip;
3767}
3768
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003769bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003770 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003771 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003772
3773 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003774 const auto &features = physical_device_features;
3775 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003776
John Zulauf71968502017-10-26 13:51:15 -06003777 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3778 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003779 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3780 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3781 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3782 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003783 }
3784
3785 // Anistropy cannot be enabled in sampler unless enabled as a feature
3786 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003787 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3788 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3789 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003790 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003791 }
John Zulauf71968502017-10-26 13:51:15 -06003792
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003793 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3794 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003795 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3796 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3797 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3798 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003799 }
3800 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3802 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3803 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3804 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003805 }
3806 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003807 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3808 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3809 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3810 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003811 }
3812 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3813 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3814 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3815 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003816 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3817 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3818 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3819 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3820 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3821 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003822 }
3823 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003824 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3825 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3826 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003827 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003828 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003829 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3830 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3831 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003832 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003833 }
3834
3835 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003836 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003837 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003838 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3839 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003840 if (sampler_reduction != nullptr) {
3841 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003842 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3843 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
3844 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003845 }
3846 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003847 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003848 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003849 if (!IsExtEnabled(device_extensions.vk_ext_sampler_filter_minmax)) {
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003850 skip |= LogError(device, "VUID-VkSamplerCreateInfo-pNext-06726",
sjfricke751b7092022-04-12 21:49:37 +09003851 "vkCreateSampler(): sampler reduction mode is %s, but extension %s is not enabled.",
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003852 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3853 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
3854 }
ziga-lunarg01be97a2022-05-01 14:30:39 +02003855
3856 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
3857 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
3858 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
3859 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
3860 "extension %s is not enabled.",
3861 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3862 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
3863 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
3864 }
3865 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003866 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003867
3868 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3869 // valid VkBorderColor value
3870 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3871 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3872 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003873 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3874 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003875 }
3876
John Zulauf275805c2017-10-26 15:34:49 -06003877 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003878 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003879 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3880 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003881 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3882 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3883 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003884 }
3885 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003886
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003887 // Check for valid Lod range
3888 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003889 skip |=
3890 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3891 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003892 }
3893
3894 // Check mipLodBias to device limit
3895 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003896 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3897 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3898 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003899 }
3900
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003901 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003902 if (sampler_conversion != nullptr) {
3903 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3904 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3905 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3906 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003907 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003908 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003909 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3910 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3911 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3912 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3913 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3914 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3915 }
3916 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003917
3918 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3919 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3920 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3921 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3922 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3923 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3924 }
3925 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3926 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3927 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3928 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3929 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3930 }
3931 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3932 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3933 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3934 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3935 pCreateInfo->minLod, pCreateInfo->maxLod);
3936 }
3937 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3938 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3939 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3940 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3941 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3942 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3943 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3944 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3945 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3946 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3947 }
3948 if (pCreateInfo->anisotropyEnable) {
3949 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3950 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3951 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3952 }
3953 if (pCreateInfo->compareEnable) {
3954 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3955 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3956 "pCreateInfo->compareEnable must be VK_FALSE");
3957 }
3958 if (pCreateInfo->unnormalizedCoordinates) {
3959 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3960 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3961 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3962 }
3963 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003964
Piers Daniell833b9492021-11-20 11:47:10 -07003965 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3966 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3967 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3968 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3969 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3970 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3971 }
3972 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3973 if (!custom_create_info) {
3974 skip |= LogError(
3975 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3976 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3977 "struct in pNext chain.\n",
3978 string_VkBorderColor(pCreateInfo->borderColor));
3979 } else {
3980 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3981 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3982 !FormatIsSampledInt(custom_create_info->format)) ||
3983 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3984 !FormatIsSampledFloat(custom_create_info->format)))) {
3985 skip |=
3986 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003987 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3988 "whose type does not match\n",
3989 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003990 ;
3991 }
3992 }
3993 }
3994
3995 const auto *border_color_component_mapping =
3996 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3997 if (border_color_component_mapping) {
3998 const auto *border_color_swizzle_features =
3999 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4000 bool border_color_swizzle_features_enabled =
4001 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4002 if (!border_color_swizzle_features_enabled) {
4003 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4004 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4005 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004006 }
4007 }
4008 }
4009
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004010 return skip;
4011}
4012
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004013bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
4014 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4015 const char *func_name) const {
4016 bool skip = false;
4017
4018 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4019 uint32_t mutable_type_count = 0;
4020 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4021 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4022 }
4023 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4024 if (mutable_type_count == 0) {
4025 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4026 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4027 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4028 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4029 "].descriptorTypeCount is 0.",
4030 func_name, i, i);
4031 }
4032 } else {
4033 if (mutable_type_count > 0) {
4034 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4035 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4036 "].descriptorType is %s, but "
4037 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4038 "].descriptorTypeCount is not 0.",
4039 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4040 }
4041 }
4042 }
4043
4044 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4045 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4046 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
4047 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4048 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4049 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4050 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4051 func_name, j, k);
4052 break;
4053 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4054 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4055 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4056 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4057 func_name, j, k);
4058 break;
4059 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4060 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4061 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4062 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4063 func_name, j, k);
4064 break;
4065 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4066 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4067 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4068 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4069 func_name, j, k);
4070 break;
4071 default:
4072 break;
4073 }
4074 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4075 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4076 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4077 skip |=
4078 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4079 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4080 "].pDescriptorTypes[%" PRIu32
4081 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4082 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4083 func_name, j, k, j, l,
4084 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4085 }
4086 }
4087 }
4088 }
4089
4090 return skip;
4091}
4092
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004093bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4094 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4095 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004096 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004097 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004098
ziga-lunargfc6896f2021-10-15 18:46:12 +02004099 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4100 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4101 bool mutable_descriptor_type_features_enabled =
4102 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4103
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004104 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4105 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4106 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4107 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004108 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4109 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4110 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4111 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4112 ++descriptor_index) {
4113 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004114 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004115 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004116 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4117 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004118 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004119 }
4120 }
4121 }
4122
4123 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4124 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4125 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004126 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004127 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4128 "].descriptorCount is not 0, "
4129 "pCreateInfo->pBindings[%" PRIu32
4130 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004131 "values.",
4132 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004133 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004134
4135 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4136 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4137 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004138 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4139 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4140 "].descriptorCount is not 0 and "
4141 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4142 "].stageFlags "
4143 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4144 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004145 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004146
4147 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4148 if (!mutable_descriptor_type) {
4149 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4150 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4151 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4152 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4153 i);
4154 }
4155 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4156 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4157 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4158 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4159 "pImmutableSamplers is not NULL.",
4160 i);
4161 }
4162 if (!mutable_descriptor_type_features_enabled) {
4163 skip |= LogError(
4164 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4165 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4166 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4167 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4168 i);
4169 }
4170 }
4171
4172 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4173 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4174 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4175 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4176 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4177 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4178 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004179 }
4180 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004181
4182 if (mutable_descriptor_type) {
4183 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4184 "vkDescriptorSetLayoutCreateInfo");
4185 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004186 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004187 if (pCreateInfo) {
4188 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4189 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4190 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4191 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4192 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4193 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4194 }
4195 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4196 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4197 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4198 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4199 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4200 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4201 }
4202 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4203 !mutable_descriptor_type_features_enabled) {
4204 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4205 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4206 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4207 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4208 }
4209 }
4210
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004211 return skip;
4212}
4213
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004214bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4215 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004216 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004217 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4218 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4219 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004220 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4221 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004222}
4223
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004224bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4225 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004226 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004227 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004228
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004229 if (pDescriptorWrites != NULL) {
4230 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4231 // descriptorCount must be greater than 0
4232 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004233 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4234 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4235 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004236 }
4237
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004238 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004239 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004240 // dstSet must be a valid VkDescriptorSet handle
4241 skip |= validate_required_handle(vkCallingFunction,
4242 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4243 pDescriptorWrites[i].dstSet);
4244 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004245
4246 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4247 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4248 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4249 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4250 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004251 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004252 if (!isPushDescriptor) {
4253 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4254 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4255 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4256 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4257 // ObjectLifetimes::ValidateDescriptorWrite.
4258 skip |= LogError(
4259 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4260 "%s(): if pDescriptorWrites[%" PRIu32
4261 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4262 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4263 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4264 vkCallingFunction, i, i);
4265 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4266 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4267 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4268 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4269 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4270 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4271 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4272 "%s(): if pDescriptorWrites[%" PRIu32
4273 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4274 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4275 "].pImageInfo must not be NULL.",
4276 vkCallingFunction, i, i);
4277 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004278 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4279 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004280 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4281 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004282 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4283 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004284 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004285 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4286 ParameterName::IndexVector{i, descriptor_index}),
4287 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004288 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004289 }
4290 }
4291 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4292 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4293 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4294 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4295 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4296 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4297 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004298 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004299 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004300 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004301 "%s(): if pDescriptorWrites[%" PRIu32
4302 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004303 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4304 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004305 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004306 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004307 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004308 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004309 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004310 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004311 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4312 ++descriptor_index) {
4313 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4314 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4315 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004316 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004317 "%s(): if pDescriptorWrites[%" PRIu32
4318 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004319 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004320 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4321 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004322 }
4323 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004324 }
4325 }
4326 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4327 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004328 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004329 }
4330
4331 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4332 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004333 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004334 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4335 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004336 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004337 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004338 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004339 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004340 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004341 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004342 }
4343 }
4344 }
4345 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4346 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004347 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004348 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4349 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004350 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004351 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004352 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004353 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004354 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004355 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004356 }
4357 }
4358 }
4359 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004360 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4361 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004362 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004363 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004364 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4365 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4366 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4367 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004368 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004369 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4370 pDescriptorWrites[i].descriptorCount);
4371 }
4372 // further checks only if we have right structtype
4373 if (pnext_struct) {
4374 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4375 skip |= LogError(
4376 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004377 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4378 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004379 ".",
4380 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004381 }
sourav parmarbcee7512020-12-28 14:34:49 -08004382 if (pnext_struct->accelerationStructureCount == 0) {
4383 skip |= LogError(device,
4384 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004385 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004386 }
4387 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004388 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004389 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4390 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4391 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4392 skip |= LogError(device,
4393 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4394 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004395 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004396 }
4397 }
4398 }
sourav parmarbcee7512020-12-28 14:34:49 -08004399 }
4400 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004401 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004402 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4403 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4404 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4405 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004406 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004407 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4408 pDescriptorWrites[i].descriptorCount);
4409 }
4410 // further checks only if we have right structtype
4411 if (pnext_struct) {
4412 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4413 skip |= LogError(
4414 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004415 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4416 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004417 ".",
4418 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004419 }
sourav parmarbcee7512020-12-28 14:34:49 -08004420 if (pnext_struct->accelerationStructureCount == 0) {
4421 skip |= LogError(device,
4422 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004423 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004424 }
4425 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004426 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004427 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4428 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4429 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4430 skip |= LogError(device,
4431 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4432 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004433 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004434 }
4435 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004436 }
4437 }
4438 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004439 }
4440 }
4441 return skip;
4442}
4443
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004444bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4445 const VkWriteDescriptorSet *pDescriptorWrites,
4446 uint32_t descriptorCopyCount,
4447 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004448 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004449}
4450
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004451bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004452 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004453 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004454 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4455}
4456
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004457bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4458 const VkAllocationCallbacks *pAllocator,
4459 VkRenderPass *pRenderPass) const {
4460 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4461}
4462
Mike Schuchardt2df08912020-12-15 16:28:09 -08004463bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004464 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004465 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004466 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4467}
4468
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004469bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4470 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004471 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004472 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004473
4474 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4475 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4476 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004477 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4478 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004479 return skip;
4480}
4481
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004482bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004483 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004484 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004485
4486 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4487 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004488 bool cb_is_secondary;
4489 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004490 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004491 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4492 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004493
Tony-LunarG3c287f62020-12-17 12:39:49 -07004494 if (cb_is_secondary) {
4495 // Implicit VUs
4496 // validate only sType here; pointer has to be validated in core_validation
4497 const bool k_not_required = false;
4498 const char *k_no_vuid = nullptr;
4499 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4500 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004501 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4502 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004503
Tony-LunarG3c287f62020-12-17 12:39:49 -07004504 if (info) {
4505 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004506 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004507 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4508 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004509 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004510 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004511 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4512 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4513 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4514 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004515
Tony-LunarG3c287f62020-12-17 12:39:49 -07004516 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004517
Tony-LunarG3c287f62020-12-17 12:39:49 -07004518 // Explicit VUs
4519 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004520 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004521 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4522 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4523 cmd_name);
4524 }
4525
4526 if (physical_device_features.inheritedQueries) {
4527 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004528 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4529 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4530 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004531 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004532 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004533 }
4534
4535 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004536 skip |=
4537 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4538 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4539 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4540 } else { // !pipelineStatisticsQuery
4541 skip |=
4542 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4543 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004544 }
4545
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004546 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004547 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004548 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004549 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4550 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4551 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004552 commandBuffer,
4553 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004554 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4555 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4556 }
Petr Kraus139757b2019-08-15 17:19:33 +02004557 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004558
4559 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4560 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4561 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4562 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4563 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4564 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4565 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4566 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4567 }
Petr Kraus139757b2019-08-15 17:19:33 +02004568 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004569 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004570 return skip;
4571}
4572
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004573bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004574 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004575 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004576
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004577 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004578 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004579 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4580 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4581 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004582 }
4583 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004584 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4585 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4586 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004587 }
4588 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004589 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004590 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004591 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4592 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4593 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4594 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004595 }
4596 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004597
4598 if (pViewports) {
4599 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4600 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004601 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004602 skip |= manual_PreCallValidateViewport(
4603 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004604 }
4605 }
4606
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004607 return skip;
4608}
4609
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004610bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004611 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004612 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004613
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004614 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004615 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004616 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4617 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4618 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004619 }
4620 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004621 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4622 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4623 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004624 }
4625 } else { // multiViewport enabled
4626 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004627 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004628 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4629 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4630 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4631 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004632 }
4633 }
4634
Petr Kraus6260f0a2018-02-27 21:15:55 +01004635 if (pScissors) {
4636 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4637 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004638
Petr Kraus6260f0a2018-02-27 21:15:55 +01004639 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004640 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4641 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4642 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004643 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004644
Petr Kraus6260f0a2018-02-27 21:15:55 +01004645 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004646 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4647 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4648 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004649 }
4650
4651 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4652 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004653 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4654 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4655 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4656 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004657 }
4658
4659 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4660 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004661 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4662 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4663 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4664 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004665 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004666 }
4667 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004668
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004669 return skip;
4670}
4671
Jeff Bolz5c801d12019-10-09 10:38:45 -05004672bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004673 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004674
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004675 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004676 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4677 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004678 }
4679
4680 return skip;
4681}
4682
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004683bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004684 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004685 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004686
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004687 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004688 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004689 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4690 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004691 }
4692 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004693 skip |=
4694 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4695 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4696 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004697 }
4698 return skip;
4699}
4700
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004701bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004702 VkDeviceSize offset, uint32_t drawCount,
4703 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004704 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004705 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004706 skip |=
4707 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4708 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4709 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004710 }
4711 if (drawCount > device_limits.maxDrawIndirectCount) {
4712 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004713 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4714 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004715 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004716 }
4717 return skip;
4718}
4719
sfricke-samsungf692b972020-05-02 08:00:45 -07004720bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4721 VkDeviceSize countBufferOffset, bool khr) const {
4722 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004723 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004724 if (offset & 3) {
4725 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004726 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004727 }
4728
4729 if (countBufferOffset & 3) {
4730 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004731 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004732 countBufferOffset);
4733 }
4734 return skip;
4735}
4736
4737bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4738 VkDeviceSize offset, VkBuffer countBuffer,
4739 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4740 uint32_t stride) const {
4741 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4742}
4743
4744bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4745 VkDeviceSize offset, VkBuffer countBuffer,
4746 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4747 uint32_t stride) const {
4748 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4749}
4750
4751bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4752 VkDeviceSize countBufferOffset, bool khr) const {
4753 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004754 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004755 if (offset & 3) {
4756 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004757 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004758 }
4759
4760 if (countBufferOffset & 3) {
4761 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004762 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004763 countBufferOffset);
4764 }
4765 return skip;
4766}
4767
4768bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4769 VkDeviceSize offset, VkBuffer countBuffer,
4770 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4771 uint32_t stride) const {
4772 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4773}
4774
4775bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4776 VkDeviceSize offset, VkBuffer countBuffer,
4777 VkDeviceSize countBufferOffset,
4778 uint32_t maxDrawCount, uint32_t stride) const {
4779 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4780}
4781
Tony-LunarG4490de42021-06-21 15:49:19 -06004782bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4783 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4784 uint32_t firstInstance, uint32_t stride) const {
4785 bool skip = false;
4786 if (stride & 3) {
4787 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4788 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4789 }
4790 if (drawCount && nullptr == pVertexInfo) {
4791 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4792 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4793 "one or more valid instances of VkMultiDrawInfoEXT structures");
4794 }
4795 return skip;
4796}
4797
4798bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4799 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4800 uint32_t instanceCount, uint32_t firstInstance,
4801 uint32_t stride, const int32_t *pVertexOffset) const {
4802 bool skip = false;
4803 if (stride & 3) {
4804 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4805 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4806 }
4807 if (drawCount && nullptr == pIndexInfo) {
4808 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4809 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4810 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4811 }
4812 return skip;
4813}
4814
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004815bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4816 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004817 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004818 bool skip = false;
4819 for (uint32_t rect = 0; rect < rectCount; rect++) {
4820 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004821 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004822 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004823 }
sfricke-samsung10867682020-04-25 02:20:39 -07004824 if (pRects[rect].rect.extent.width == 0) {
4825 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004826 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004827 }
4828 if (pRects[rect].rect.extent.height == 0) {
4829 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004830 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004831 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004832 }
4833 return skip;
4834}
4835
Andrew Fobel3abeb992020-01-20 16:33:22 -05004836bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4837 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4838 VkImageFormatProperties2 *pImageFormatProperties,
4839 const char *apiName) const {
4840 bool skip = false;
4841
4842 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004843 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004844 if (image_stencil_struct != nullptr) {
4845 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4846 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4847 // No flags other than the legal attachment bits may be set
4848 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4849 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004850 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4851 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4852 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4853 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4854 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004855 }
4856 }
4857 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004858 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4859 if (image_drm_format) {
4860 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4861 skip |= LogError(
4862 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4863 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4864 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4865 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4866 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004867 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4868 skip |= LogError(
4869 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4870 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4871 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4872 apiName, image_drm_format->queueFamilyIndexCount);
4873 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004874 } else {
4875 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4876 skip |= LogError(
4877 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4878 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4879 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4880 apiName);
4881 }
4882 }
4883 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4884 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4885 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4886 if (!format_list || format_list->viewFormatCount == 0) {
4887 skip |= LogError(
4888 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4889 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4890 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4891 apiName);
4892 }
4893 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004894 }
4895
4896 return skip;
4897}
4898
4899bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4900 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4901 VkImageFormatProperties2 *pImageFormatProperties) const {
4902 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4903 "vkGetPhysicalDeviceImageFormatProperties2");
4904}
4905
4906bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4907 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4908 VkImageFormatProperties2 *pImageFormatProperties) const {
4909 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4910 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4911}
4912
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004913bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4914 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4915 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4916 bool skip = false;
4917
4918 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4919 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4920 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4921 }
4922
4923 return skip;
4924}
4925
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004926bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4927 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4928 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4929 bool skip = false;
4930
4931 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4932 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4933 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4934 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4935 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4936 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4937 }
4938
ziga-lunarg42f884b2021-08-25 16:13:20 +02004939 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004940}
4941
sfricke-samsung3999ef62020-02-09 17:05:59 -08004942bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4943 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4944 bool skip = false;
4945
4946 if (pRegions != nullptr) {
4947 for (uint32_t i = 0; i < regionCount; i++) {
4948 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004949 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004950 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004951 }
4952 }
4953 }
4954 return skip;
4955}
4956
Jeff Leger178b1e52020-10-05 12:22:23 -04004957bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4958 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4959 bool skip = false;
4960
4961 if (pCopyBufferInfo->pRegions != nullptr) {
4962 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4963 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004964 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004965 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004966 }
4967 }
4968 }
4969 return skip;
4970}
4971
Tony-LunarGef035472021-11-02 10:23:33 -06004972bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
4973 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
4974 bool skip = false;
4975
4976 if (pCopyBufferInfo->pRegions != nullptr) {
4977 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4978 if (pCopyBufferInfo->pRegions[i].size == 0) {
4979 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
4980 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
4981 }
4982 }
4983 }
4984 return skip;
4985}
4986
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004987bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004988 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4989 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004990 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004991
4992 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004993 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4994 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4995 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004996 }
4997
4998 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004999 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5000 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5001 "), must be greater than zero and less than or equal to 65536.",
5002 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005003 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005004 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5005 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5006 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005007 }
5008 return skip;
5009}
5010
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005011bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005012 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005013 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005014
5015 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005016 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5017 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5018 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005019 }
5020
5021 if (size != VK_WHOLE_SIZE) {
5022 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005023 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005024 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5025 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005026 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005027 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5028 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005029 }
5030 }
5031 return skip;
5032}
5033
sfricke-samsunga1d00272021-03-10 21:37:41 -08005034bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005035 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005036
5037 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005038 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5039 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5040 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5041 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005042 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005043 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5044 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5045 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005046 }
5047
5048 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5049 // queueFamilyIndexCount uint32_t values
5050 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005051 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005052 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005053 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005054 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5055 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005056 }
5057 }
5058
Dave Houlton413a6782018-05-22 13:01:54 -06005059 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005060 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005061
sfricke-samsunga1d00272021-03-10 21:37:41 -08005062 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5063 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5064 if (format_list_info) {
5065 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5066 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5067 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5068 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005069 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5070 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005071 func_name, viewFormatCount);
5072 }
5073
5074 // Using the first format, compare the rest of the formats against it that they are compatible
5075 for (uint32_t i = 1; i < viewFormatCount; i++) {
5076 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5077 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5078 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5079 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005080 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5081 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005082 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5083 string_VkFormat(format_list_info->pViewFormats[i]));
5084 }
5085 }
5086 }
5087
5088 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5089 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5090 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5091 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5092 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5093 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5094 func_name);
5095 } else {
5096 if (format_list_info == nullptr) {
5097 skip |= LogError(
5098 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5099 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5100 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5101 func_name);
5102 } else if (format_list_info->viewFormatCount == 0) {
5103 skip |= LogError(
5104 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5105 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5106 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5107 func_name);
5108 } else {
5109 bool found_base_format = false;
5110 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5111 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5112 found_base_format = true;
5113 break;
5114 }
5115 }
5116 if (!found_base_format) {
5117 skip |=
5118 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5119 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5120 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5121 "pCreateInfo->imageFormat.",
5122 func_name);
5123 }
5124 }
5125 }
5126 }
5127 }
5128 return skip;
5129}
5130
5131bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5132 const VkAllocationCallbacks *pAllocator,
5133 VkSwapchainKHR *pSwapchain) const {
5134 bool skip = false;
5135 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5136 return skip;
5137}
5138
5139bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5140 const VkSwapchainCreateInfoKHR *pCreateInfos,
5141 const VkAllocationCallbacks *pAllocator,
5142 VkSwapchainKHR *pSwapchains) const {
5143 bool skip = false;
5144 if (pCreateInfos) {
5145 for (uint32_t i = 0; i < swapchainCount; i++) {
5146 std::stringstream func_name;
5147 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5148 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5149 }
5150 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005151 return skip;
5152}
5153
Jeff Bolz5c801d12019-10-09 10:38:45 -05005154bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005155 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005156
5157 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005158 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005159 if (present_regions) {
5160 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005161 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005162 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5163 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005164 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005165 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5166 "extension swapchainCount is %i. These values must be equal.",
5167 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005168 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005169 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005170 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5171 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005172 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5173 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5174 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005175 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005176 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005177 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005178 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005179 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005180 }
5181 }
5182
5183 return skip;
5184}
5185
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005186bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5187 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5188 const VkAllocationCallbacks *pAllocator,
5189 VkDisplayModeKHR *pMode) const {
5190 bool skip = false;
5191
5192 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5193 if (display_mode_parameters.visibleRegion.width == 0) {
5194 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5195 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5196 }
5197 if (display_mode_parameters.visibleRegion.height == 0) {
5198 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5199 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5200 }
5201 if (display_mode_parameters.refreshRate == 0) {
5202 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5203 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5204 }
5205
5206 return skip;
5207}
5208
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005209#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005210bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5211 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5212 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005213 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005214 bool skip = false;
5215
5216 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005217 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5218 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005219 }
5220
5221 return skip;
5222}
5223#endif // VK_USE_PLATFORM_WIN32_KHR
5224
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005225static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5226 bool partial_overlap = false;
5227
5228 static const std::vector<VkDescriptorType> all_descriptor_types = {
5229 VK_DESCRIPTOR_TYPE_SAMPLER,
5230 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5231 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5232 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5233 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5234 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5235 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5236 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5237 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5238 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5239 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5240 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5241 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5242 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5243 };
5244
5245 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5246 if (mutable_descriptor_type) {
5247 std::vector<VkDescriptorType> first_types, second_types;
5248 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5249 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5250 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5251 }
5252 } else {
5253 first_types = all_descriptor_types;
5254 }
5255 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5256 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5257 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5258 }
5259 } else {
5260 second_types = all_descriptor_types;
5261 }
5262
5263 bool complete_overlap = first_types.size() == second_types.size();
5264 bool disjoint = true;
5265 for (const auto first_type : first_types) {
5266 bool found = false;
5267 for (const auto second_type : second_types) {
5268 if (first_type == second_type) {
5269 found = true;
5270 break;
5271 }
5272 }
5273 if (found) {
5274 disjoint = false;
5275 } else {
5276 complete_overlap = false;
5277 }
5278 if (!disjoint && !complete_overlap) {
5279 partial_overlap = true;
5280 break;
5281 }
5282 }
5283 }
5284
5285 return partial_overlap;
5286}
5287
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005288bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005289 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005290 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005291 bool skip = false;
5292
5293 if (pCreateInfo) {
5294 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005295 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5296 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005297 }
5298
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005299 const auto *mutable_descriptor_type_features =
5300 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5301 bool mutable_descriptor_type_enabled =
5302 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5303
Petr Krausc8655be2017-09-27 18:56:51 +02005304 if (pCreateInfo->pPoolSizes) {
5305 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5306 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005307 skip |= LogError(
5308 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005309 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005310 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005311 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5312 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005313 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5314 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5315 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5316 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5317 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005318 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005319 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5320 skip |=
5321 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5322 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5323 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5324 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5325 i);
5326 }
5327 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5328 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5329 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5330 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5331 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5332 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5333 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5334 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5335 " and have sets which partially overlap.",
5336 i, j);
5337 }
5338 }
5339 }
5340 }
Petr Krausc8655be2017-09-27 18:56:51 +02005341 }
5342 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005343
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005344 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5345 skip |=
5346 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5347 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5348 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5349 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005350 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5351 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5352 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5353 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5354 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5355 }
Petr Krausc8655be2017-09-27 18:56:51 +02005356 }
5357
5358 return skip;
5359}
5360
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005361bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005362 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005363 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005364
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005365 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005366 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005367 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5368 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5369 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005370 }
5371
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005372 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005373 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005374 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5375 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5376 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005377 }
5378
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005379 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005380 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005381 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5382 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5383 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005384 }
5385
5386 return skip;
5387}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005388
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005389bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005390 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005391 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005392
5393 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005394 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5395 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005396 }
5397 return skip;
5398}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005399
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005400bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5401 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005402 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005403 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005404
5405 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005406 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005407 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005408 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5409 "vkCmdDispatch(): baseGroupX (%" PRIu32
5410 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5411 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005412 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005413 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5414 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5415 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5416 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005417 }
5418
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005419 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005420 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005421 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5422 "vkCmdDispatch(): baseGroupY (%" PRIu32
5423 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5424 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005425 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005426 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5427 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5428 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5429 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005430 }
5431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005432 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005433 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005434 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5435 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5436 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5437 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005438 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005439 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5440 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5441 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5442 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005443 }
5444
5445 return skip;
5446}
5447
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005448bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5449 VkPipelineBindPoint pipelineBindPoint,
5450 VkPipelineLayout layout, uint32_t set,
5451 uint32_t descriptorWriteCount,
5452 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005453 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005454}
5455
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005456bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5457 uint32_t firstExclusiveScissor,
5458 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005459 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005460 bool skip = false;
5461
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005462 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005463 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005464 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005465 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5466 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5467 ") is not 0.",
5468 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005469 }
5470 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005471 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005472 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5473 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5474 ") is not 1.",
5475 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005476 }
5477 } else { // multiViewport enabled
5478 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005479 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005480 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5481 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5482 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5483 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005484 }
5485 }
5486
Jeff Bolz3e71f782018-08-29 23:15:45 -05005487 if (pExclusiveScissors) {
5488 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5489 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5490
5491 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005492 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5493 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5494 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005495 }
5496
5497 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005498 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5499 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5500 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005501 }
5502
5503 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5504 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005505 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5506 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5507 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5508 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005509 }
5510
5511 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5512 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005513 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5514 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5515 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5516 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005517 }
5518 }
5519 }
5520
5521 return skip;
5522}
5523
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005524bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5525 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005526 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005527 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005528 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5529 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5530 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5531 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5532 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5533 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005534 }
5535
5536 return skip;
5537}
5538
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005539bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5540 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005541 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005542 bool skip = false;
5543
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005544 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005545 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005546 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005547 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5548 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5549 ") is not 0.",
5550 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005551 }
5552 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005553 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005554 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5555 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5556 ") is not 1.",
5557 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005558 }
5559 }
5560
Jeff Bolz9af91c52018-09-01 21:53:57 -05005561 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005562 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005563 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5564 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5565 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5566 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005567 }
5568
5569 return skip;
5570}
5571
Jeff Bolz5c801d12019-10-09 10:38:45 -05005572bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5573 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5574 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005575 bool skip = false;
5576
Dave Houlton142c4cb2018-10-17 15:04:41 -06005577 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005578 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5579 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5580 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005581 }
5582
5583 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005584 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005585 }
5586
5587 return skip;
5588}
5589
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005590bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005591 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005592 bool skip = false;
5593
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005594 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005595 skip |= LogError(
5596 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005597 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5598 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005599 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005600 }
5601
5602 return skip;
5603}
5604
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005605bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5606 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005607 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005608 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005609 static const int condition_multiples = 0b0011;
5610 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005611 skip |= LogError(
5612 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005613 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005614 }
Lockee1c22882019-06-10 16:02:54 -06005615 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005616 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5617 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5618 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5619 stride);
Lockee1c22882019-06-10 16:02:54 -06005620 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005621 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005622 skip |= LogError(
5623 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005624 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5625 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005626 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005627 if (drawCount > device_limits.maxDrawIndirectCount) {
5628 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005629 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5630 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005631 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005632 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005633 return skip;
5634}
5635
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005636bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5637 VkDeviceSize offset, VkBuffer countBuffer,
5638 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005639 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005640 bool skip = false;
5641
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005642 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005643 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5644 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5645 "), is not a multiple of 4.",
5646 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005647 }
5648
5649 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005650 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5651 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5652 "), is not a multiple of 4.",
5653 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005654 }
5655
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005656 return skip;
5657}
5658
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005659bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005660 const VkAllocationCallbacks *pAllocator,
5661 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005662 bool skip = false;
5663
5664 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5665 if (pCreateInfo != nullptr) {
5666 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5667 // VkQueryPipelineStatisticFlagBits values
5668 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5669 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005670 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5671 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5672 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5673 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005674 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005675 if (pCreateInfo->queryCount == 0) {
5676 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5677 "vkCreateQueryPool(): queryCount must be greater than zero.");
5678 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005679 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005680 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005681}
5682
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005683bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5684 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005685 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005686 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5687 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005688}
5689
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005690void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005691 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5692 VkResult result) {
5693 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005694 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005695}
5696
Mike Schuchardt2df08912020-12-15 16:28:09 -08005697void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005698 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5699 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005700 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005701 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005702 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005703}
5704
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005705void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5706 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005707 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005708 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005709 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005710}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005711
Tony-LunarG3c287f62020-12-17 12:39:49 -07005712void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005713 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005714 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005715 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005716 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005717 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005718 }
5719 }
5720}
5721
5722void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005723 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005724 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005725 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5726 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5727 }
5728}
5729
5730void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005731 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005732 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005733 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5734 if (item->second == commandPool) {
5735 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005736 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005737 ++item;
5738 }
5739 }
5740}
5741
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005742bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005743 const VkAllocationCallbacks *pAllocator,
5744 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005745 bool skip = false;
5746
5747 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005748 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005749 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005750 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5751 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005752 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005753
5754 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005755 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005756 if (flags_info) {
5757 flags = flags_info->flags;
5758 }
5759
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005760 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005761 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005762 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005763 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5764 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005765 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005766 }
5767
5768#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005769 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005770#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005771 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5772 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005773#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005774 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005775#endif
5776
5777 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005778 skip |= LogError(
5779 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005780 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5781 }
5782 if (
5783#ifdef VK_USE_PLATFORM_WIN32_KHR
5784 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5785#endif
5786 (import_memory_fd && import_memory_fd->handleType) ||
5787#ifdef VK_USE_PLATFORM_ANDROID_KHR
5788 (import_memory_ahb && import_memory_ahb->buffer) ||
5789#endif
5790 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005791 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5792 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005793 }
5794 }
5795
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005796 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5797 if (export_memory) {
5798 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5799 if (export_memory_nv) {
5800 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5801 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5802 "VkExportMemoryAllocateInfoNV");
5803 }
5804#ifdef VK_USE_PLATFORM_WIN32_KHR
5805 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5806 if (export_memory_win32_nv) {
5807 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5808 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5809 "VkExportMemoryWin32HandleInfoNV");
5810 }
5811#endif
5812 }
5813
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005814 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005815 VkBool32 capture_replay = false;
5816 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005817 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005818 if (vulkan_12_features) {
5819 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5820 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5821 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005822 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005823 if (bda_features) {
5824 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5825 buffer_device_address = bda_features->bufferDeviceAddress;
5826 }
5827 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005828 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005829 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005830 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005831 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005832 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005833 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005834 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005835 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005836 }
5837 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005838 }
5839 return skip;
5840}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005841
Jason Macnak192fa0e2019-07-26 15:07:16 -07005842bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005843 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005844 bool skip = false;
5845
5846 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5847 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5848 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005849 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005850 } else {
5851 uint32_t vertex_component_size = 0;
5852 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5853 vertex_component_size = 4;
5854 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5855 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5856 vertex_component_size = 2;
5857 }
5858 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005859 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005860 }
5861 }
5862
5863 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5864 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005865 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005866 } else {
5867 uint32_t index_element_size = 0;
5868 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5869 index_element_size = 4;
5870 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5871 index_element_size = 2;
5872 }
5873 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005874 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005875 }
5876 }
5877 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5878 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005879 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005880 }
5881 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005882 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005883 }
5884 }
5885
5886 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005887 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005888 }
5889
5890 return skip;
5891}
5892
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005893bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5894 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005895 bool skip = false;
5896
5897 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005898 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005899 }
5900 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005901 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005902 }
5903
5904 return skip;
5905}
5906
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005907bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5908 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005909 bool skip = false;
5910 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005911 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005912 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005913 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005914 }
5915 return skip;
5916}
5917
5918bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005919 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005920 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005921 bool skip = false;
5922 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005923 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5924 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5925 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005926 }
5927 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005928 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5929 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5930 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005931 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005932 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5933 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5934 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5935 }
Jason Macnak5c954952019-07-09 15:46:12 -07005936 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5937 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005938 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5939 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5940 "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 -07005941 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005942 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005943 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005944 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5945 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005946 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5947 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005948 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005949 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005950 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5951 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5952 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005953 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005954 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005955 uint64_t total_triangle_count = 0;
5956 for (uint32_t i = 0; i < info.geometryCount; i++) {
5957 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005958
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005959 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005960
Jason Macnak5c954952019-07-09 15:46:12 -07005961 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5962 continue;
5963 }
5964 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5965 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005966 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005967 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5968 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5969 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005970 }
5971 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005972 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5973 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5974 for (uint32_t i = 1; i < info.geometryCount; i++) {
5975 const VkGeometryNV &geometry = info.pGeometries[i];
5976 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005977 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005978 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5979 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005980 "info.pGeometries[0].geometryType.",
5981 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005982 }
5983 }
5984 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005985 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5986 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5987 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5988 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5989 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5990 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5991 }
5992 }
5993 skip |=
5994 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005995 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005996 return skip;
5997}
5998
Ricardo Garciaa4935972019-02-21 17:43:18 +01005999bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6000 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006001 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006002 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006003 if (pCreateInfo) {
6004 if ((pCreateInfo->compactedSize != 0) &&
6005 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006006 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6007 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6008 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6009 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006010 }
Jason Macnak5c954952019-07-09 15:46:12 -07006011
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006012 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006013 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006014 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006015 return skip;
6016}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006017
Jeff Bolz5c801d12019-10-09 10:38:45 -05006018bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6019 const VkAccelerationStructureInfoNV *pInfo,
6020 VkBuffer instanceData, VkDeviceSize instanceOffset,
6021 VkBool32 update, VkAccelerationStructureNV dst,
6022 VkAccelerationStructureNV src, VkBuffer scratch,
6023 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006024 bool skip = false;
6025
6026 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006027 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006028 }
6029
6030 return skip;
6031}
6032
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006033bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6034 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6035 VkAccelerationStructureKHR *pAccelerationStructure) const {
6036 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006037 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006038 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006039 if (!acceleration_structure_features ||
6040 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6041 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6042 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6043 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006044 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006045 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6046 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006047 (acceleration_structure_features &&
6048 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006049 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006050 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6051 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6052 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6053 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006054 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006055 if (pCreateInfo->deviceAddress &&
6056 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6057 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6058 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6059 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6060 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006061 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6062 (acceleration_structure_features &&
6063 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6064 skip |= LogError(
6065 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6066 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6067 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6068 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006069 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6070 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006071 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6072 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006073 }
sourav parmar83c31b12020-05-06 12:30:54 -07006074 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006075 return skip;
6076}
6077
Jason Macnak5c954952019-07-09 15:46:12 -07006078bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6079 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006080 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006081 bool skip = false;
6082 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006083 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6084 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006085 }
6086 return skip;
6087}
6088
sourav parmarcd5fb182020-07-17 12:58:44 -07006089bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6090 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6091 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6092 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006093 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006094 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006095 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006096 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006097 }
6098 return skip;
6099}
6100
Peter Chen85366392019-05-14 15:20:11 -04006101bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6102 uint32_t createInfoCount,
6103 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6104 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006105 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006106 bool skip = false;
6107
6108 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006109 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6110 std::stringstream msg;
6111 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6112 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6113 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006114 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006115 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006116 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006117 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6118 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6119 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6120 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006121 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006122
6123 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006124 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006125 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6126 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6127 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6128 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6129 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6130 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6131 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6132 }
6133 }
6134
sourav parmarf4a78252020-04-10 13:04:21 -07006135 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6136 skip |=
6137 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6138 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6139 }
6140 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6141 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6142 skip |=
6143 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6144 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6145 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6146 }
6147 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6148 if (pCreateInfos[i].basePipelineIndex != -1) {
6149 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6150 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6151 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6152 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6153 "and pCreateInfos->basePipelineIndex is not -1.");
6154 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006155 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006156 skip |=
6157 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6158 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6159 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6160 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6161 "that element.");
6162 }
sourav parmarf4a78252020-04-10 13:04:21 -07006163 }
6164 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006165 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006166 skip |=
6167 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6168 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6169 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6170 "commands pCreateInfos parameter.");
6171 }
6172 } else {
6173 if (pCreateInfos[i].basePipelineIndex != -1) {
6174 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6175 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6176 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6177 }
6178 }
6179 }
6180 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6181 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6182 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6183 }
6184 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6185 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6186 "vkCreateRayTracingPipelinesNV: flags must not include "
6187 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6188 }
6189 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6190 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6191 "vkCreateRayTracingPipelinesNV: flags must not include "
6192 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6193 }
6194 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6195 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6196 "vkCreateRayTracingPipelinesNV: flags must not include "
6197 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6198 }
6199 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6200 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6201 "vkCreateRayTracingPipelinesNV: flags must not include "
6202 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6203 }
6204 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6205 skip |= LogError(
6206 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6207 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6208 }
6209 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6210 skip |= LogError(
6211 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6212 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6213 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006214 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6215 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6216 "vkCreateRayTracingPipelinesNV: flags must not include "
6217 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6218 }
6219 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6220 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6221 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6222 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006223 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6224 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6225 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6226 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6227 }
Peter Chen85366392019-05-14 15:20:11 -04006228 }
6229
6230 return skip;
6231}
6232
sourav parmarcd5fb182020-07-17 12:58:44 -07006233bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6234 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6235 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006236 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006237 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006238 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6239 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6240 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006241 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006242 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006243 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6244 std::stringstream msg;
6245 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6246 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006247 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006248 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006249 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6250 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6251 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6252 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6253 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6254 }
6255 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6256 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6257 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6258 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6259 }
6260 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006261 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006262 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006263 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006264 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6265 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6266 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006267 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6268 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6269 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006270 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006271 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006272 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6273 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6274 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6275 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006276 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006277 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6278 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6279 }
6280 }
sourav parmarf4a78252020-04-10 13:04:21 -07006281 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006282 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6283 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006284 }
6285 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006286 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006287 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006288 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6289 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006290 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006291 }
6292 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6293 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6294 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006295 }
6296 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6297 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6298 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6299 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6300 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6301 skip |= LogError(
6302 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006303 "vkCreateRayTracingPipelinesKHR: If flags includes "
6304 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006305 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6306 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6307 "must not be VK_SHADER_UNUSED_KHR");
6308 }
6309 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6310 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6311 skip |= LogError(
6312 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006313 "vkCreateRayTracingPipelinesKHR: If flags includes "
6314 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006315 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6316 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6317 "element must not be VK_SHADER_UNUSED_KHR");
6318 }
6319 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006320 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6321 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6322 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6323 skip |= LogError(
6324 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6325 "vkCreateRayTracingPipelinesKHR: If "
6326 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6327 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6328 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6329 }
6330 }
sourav parmarf4a78252020-04-10 13:04:21 -07006331 }
6332 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6333 if (pCreateInfos[i].basePipelineIndex != -1) {
6334 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6335 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006336 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006337 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6338 "and pCreateInfos->basePipelineIndex is not -1.");
6339 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006340 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006341 skip |=
6342 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6343 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6344 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6345 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6346 "element.");
6347 }
sourav parmarf4a78252020-04-10 13:04:21 -07006348 }
6349 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006350 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006351 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006352 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006353 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6354 ") must be a valid into the calling"
6355 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006356 pCreateInfos[i].basePipelineIndex, createInfoCount);
6357 }
6358 } else {
6359 if (pCreateInfos[i].basePipelineIndex != -1) {
6360 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006361 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006362 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6363 }
6364 }
6365 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006366 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6367 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6368 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6369 "vkCreateRayTracingPipelinesKHR: If flags includes "
6370 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6371 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006372 }
6373 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6374 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6375 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6376 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6377 "pLibraryInfo and pLibraryInterface must be NULL.");
6378 }
6379 if (pCreateInfos[i].pLibraryInfo) {
6380 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6381 if (pCreateInfos[i].stageCount == 0) {
6382 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6383 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6384 "stageCount must not be 0.");
6385 }
6386 if (pCreateInfos[i].groupCount == 0) {
6387 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6388 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6389 "groupCount must not be 0.");
6390 }
6391 } else {
6392 if (pCreateInfos[i].pLibraryInterface == NULL) {
6393 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6394 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6395 "is greater than 0, its "
6396 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006397 }
6398 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006399 }
6400 if (pCreateInfos[i].pLibraryInterface) {
6401 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6402 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6403 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6404 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6405 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6406 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006407 }
6408 if (deferredOperation != VK_NULL_HANDLE) {
6409 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6410 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6411 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6412 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006413 }
6414 }
ziga-lunargdea76582021-09-17 14:38:08 +02006415 if (pCreateInfos[i].pDynamicState) {
6416 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6417 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6418 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6419 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6420 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6421 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6422 }
6423 }
6424 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006425 }
6426
6427 return skip;
6428}
6429
Mike Schuchardt21638df2019-03-16 10:52:02 -07006430#ifdef VK_USE_PLATFORM_WIN32_KHR
6431bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6432 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006433 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006434 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006435 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006436 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006437 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006438 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006439 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006440 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006441 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006442 skip |=
6443 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006444 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006445 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6446 skip |= validate_struct_type(
6447 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6448 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6449 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6450 if (pSurfaceInfo != NULL) {
6451 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6452 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6453 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6454
6455 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6456 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6457 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6458 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006459 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6460 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006461
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006462 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6463 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6464 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6465 "VK_GOOGLE_surfaceless_query is not enabled.");
6466 }
6467
Mike Schuchardt21638df2019-03-16 10:52:02 -07006468 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6469 }
6470 return skip;
6471}
6472#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006473
6474bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6475 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006476 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006477 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6478 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006479 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006480 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6481 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6482 }
6483 return skip;
6484}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006485
6486bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006487 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006488 bool skip = false;
6489
6490 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006491 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006492 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006493 }
6494
6495 return skip;
6496}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006497
6498bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006499 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006500 bool skip = false;
6501
6502 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006503 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6504 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006505 }
6506
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006507 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006508 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006509 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6510 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006511 }
6512
6513 return skip;
6514}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006515
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006516bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6517 uint32_t bindingCount, const VkBuffer *pBuffers,
6518 const VkDeviceSize *pOffsets) const {
6519 bool skip = false;
6520 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006521 skip |=
6522 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6523 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6524 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006525 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6526 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006527 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6528 ") must be less than "
6529 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006530 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6531 }
6532
Jeff Bolz165818a2020-05-08 11:19:03 -05006533 for (uint32_t i = 0; i < bindingCount; ++i) {
6534 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006535 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006536 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006537 skip |=
6538 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6539 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006540 } else {
6541 if (pOffsets[i] != 0) {
6542 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006543 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6544 "] is not 0",
6545 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006546 }
6547 }
6548 }
6549 }
6550
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006551 return skip;
6552}
6553
Mark Lobodzinski84988402019-09-11 15:27:30 -06006554bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006555 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006556 bool skip = false;
6557 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006558 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6559 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006560 }
6561 return skip;
6562}
6563
6564bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006565 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006566 bool skip = false;
6567 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006568 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6569 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006570 }
6571 return skip;
6572}
Petr Kraus3d720392019-11-13 02:52:39 +01006573
6574bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6575 VkSemaphore semaphore, VkFence fence,
6576 uint32_t *pImageIndex) const {
6577 bool skip = false;
6578
6579 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006580 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6581 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006582 }
6583
6584 return skip;
6585}
6586
6587bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6588 uint32_t *pImageIndex) const {
6589 bool skip = false;
6590
6591 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006592 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6593 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006594 }
6595
6596 return skip;
6597}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006598
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006599bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6600 uint32_t firstBinding, uint32_t bindingCount,
6601 const VkBuffer *pBuffers,
6602 const VkDeviceSize *pOffsets,
6603 const VkDeviceSize *pSizes) const {
6604 bool skip = false;
6605
6606 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6607 for (uint32_t i = 0; i < bindingCount; ++i) {
6608 if (pOffsets[i] & 3) {
6609 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6610 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6611 }
6612 }
6613
6614 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6615 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6616 "%s: The firstBinding(%" PRIu32
6617 ") index is greater than or equal to "
6618 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6619 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6620 }
6621
6622 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6623 skip |=
6624 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6625 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6626 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6627 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6628 }
6629
6630 for (uint32_t i = 0; i < bindingCount; ++i) {
6631 // pSizes is optional and may be nullptr.
6632 if (pSizes != nullptr) {
6633 if (pSizes[i] != VK_WHOLE_SIZE &&
6634 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6635 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6636 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6637 ") is not VK_WHOLE_SIZE and is greater than "
6638 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6639 cmd_name, i, pSizes[i]);
6640 }
6641 }
6642 }
6643
6644 return skip;
6645}
6646
6647bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6648 uint32_t firstCounterBuffer,
6649 uint32_t counterBufferCount,
6650 const VkBuffer *pCounterBuffers,
6651 const VkDeviceSize *pCounterBufferOffsets) const {
6652 bool skip = false;
6653
6654 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6655 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6656 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6657 "%s: The firstCounterBuffer(%" PRIu32
6658 ") index is greater than or equal to "
6659 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6660 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6661 }
6662
6663 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6664 skip |=
6665 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6666 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6667 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6668 cmd_name, firstCounterBuffer, counterBufferCount,
6669 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6670 }
6671
6672 return skip;
6673}
6674
6675bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6676 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6677 const VkBuffer *pCounterBuffers,
6678 const VkDeviceSize *pCounterBufferOffsets) const {
6679 bool skip = false;
6680
6681 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6682 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6683 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6684 "%s: The firstCounterBuffer(%" PRIu32
6685 ") index is greater than or equal to "
6686 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6687 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6688 }
6689
6690 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6691 skip |=
6692 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6693 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6694 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6695 cmd_name, firstCounterBuffer, counterBufferCount,
6696 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6697 }
6698
6699 return skip;
6700}
6701
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006702bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6703 uint32_t firstInstance, VkBuffer counterBuffer,
6704 VkDeviceSize counterBufferOffset,
6705 uint32_t counterOffset, uint32_t vertexStride) const {
6706 bool skip = false;
6707
6708 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006709 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6710 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6711 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6712 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006713 }
6714
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006715 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006716 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006717 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006718 }
6719
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006720 return skip;
6721}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006722
6723bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6724 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6725 const VkAllocationCallbacks *pAllocator,
6726 VkSamplerYcbcrConversion *pYcbcrConversion,
6727 const char *apiName) const {
6728 bool skip = false;
6729
6730 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006731 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006732 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006733 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006734 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6735 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006736 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006737 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006738 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006739
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006740#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006741 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006742 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006743#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006744 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006745#endif
6746
sfricke-samsung1a72f942020-07-25 12:09:18 -07006747 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006748
6749 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006750 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006751 const VkComponentMapping components = pCreateInfo->components;
6752 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6753 if (FormatIsXChromaSubsampled(format) == true) {
6754 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6755 skip |=
6756 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006757 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6758 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006759 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006760 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006761
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006762 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6763 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6764 skip |= LogError(
6765 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6766 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6767 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6768 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6769 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006770
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006771 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6772 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6773 skip |=
6774 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006775 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6776 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006777 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006778 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006779
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006780 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6781 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6782 skip |=
6783 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006784 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6785 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006786 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006787 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006788
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006789 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006790 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6791 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6792 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006793 skip |=
6794 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006795 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6796 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006797 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6798 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006799 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006800 }
6801
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006802 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6803 // Checks same VU multiple ways in order to give a more useful error message
6804 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6805 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6806 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6807 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6808 skip |= LogError(
6809 device, vuid,
6810 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6811 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6812 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6813 string_VkComponentSwizzle(components.b));
6814 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006815
sfricke-samsunged028b02021-09-06 23:14:51 -07006816 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6817 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006818 // 3 = no [a]
6819 // 2 = no [b,a]
6820 // 1 = no [g,b,a]
6821 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006822 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006823
sfricke-samsunged028b02021-09-06 23:14:51 -07006824 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6825 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006826 skip |= LogError(device, vuid,
6827 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6828 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6829 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6830 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006831 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006832 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6833 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6834 skip |= LogError(device, vuid,
6835 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6836 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6837 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6838 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6839 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006840 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006841 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6842 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6843 skip |= LogError(device, vuid,
6844 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6845 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6846 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6847 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6848 string_VkComponentSwizzle(components.b));
6849 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006850 }
6851 }
6852
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006853 return skip;
6854}
6855
6856bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6857 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6858 const VkAllocationCallbacks *pAllocator,
6859 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6860 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6861 "vkCreateSamplerYcbcrConversion");
6862}
6863
6864bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6865 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6866 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6867 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6868 "vkCreateSamplerYcbcrConversionKHR");
6869}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006870
6871bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6872 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6873 bool skip = false;
6874 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6875 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6876
6877 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006878 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6879 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6880 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6881 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6882 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006883 }
6884 return skip;
6885}
sourav parmara96ab1a2020-04-25 16:28:23 -07006886
6887bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006888 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006889 bool skip = false;
6890 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6891 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6892 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6893 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006894 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006895 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6896 skip |= LogError(
6897 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6898 "vkCopyAccelerationStructureToMemoryKHR: The "
6899 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6900 }
6901 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6902 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6903 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6904 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6905 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6906 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006907 return skip;
6908}
6909
6910bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6911 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6912 bool skip = false;
6913 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6914 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6915 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6916 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6917 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006918 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6919 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006920 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006921 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006922 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006923 return skip;
6924}
6925
6926bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6927 const char *api_name) const {
6928 bool skip = false;
6929 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6930 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6931 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6932 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6933 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6934 api_name);
6935 }
6936 return skip;
6937}
6938
6939bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006940 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006941 bool skip = false;
6942 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006943 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006944 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006945 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006946 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6947 "vkCopyAccelerationStructureKHR: The "
6948 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006949 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006950 return skip;
6951}
6952
6953bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6954 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6955 bool skip = false;
6956 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6957 return skip;
6958}
6959
6960bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006961 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006962 bool skip = false;
6963 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006964 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006965 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6966 }
6967 return skip;
6968}
6969
6970bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006971 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006972 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006973 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006974 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006975 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6976 skip |= LogError(
6977 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6978 "vkCopyMemoryToAccelerationStructureKHR: The "
6979 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006980 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006981 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6982 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006983 return skip;
6984}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006985
sourav parmara96ab1a2020-04-25 16:28:23 -07006986bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6987 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6988 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006989 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006990 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6991 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006992 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006993 pInfo->src.deviceAddress);
6994 }
sourav parmar83c31b12020-05-06 12:30:54 -07006995 return skip;
6996}
6997bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6998 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6999 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7000 bool skip = false;
7001 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7002 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
7003 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7004 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
7005 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7006 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
7007 }
7008 return skip;
7009}
7010bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7011 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7012 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7013 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007014 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007015 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7016 skip |= LogError(
7017 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7018 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7019 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7020 }
sourav parmar83c31b12020-05-06 12:30:54 -07007021 if (dataSize < accelerationStructureCount * stride) {
7022 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7023 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007024 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007025 dataSize, accelerationStructureCount, stride);
7026 }
7027 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7028 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
7029 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7030 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
7031 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7032 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
7033 }
7034 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
7035 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7036 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7037 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7038 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7039 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7040 stride);
7041 }
7042 }
7043 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
7044 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7045 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7046 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7047 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7048 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7049 stride);
7050 }
7051 }
sourav parmar83c31b12020-05-06 12:30:54 -07007052 return skip;
7053}
7054bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7055 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7056 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007057 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007058 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7059 skip |= LogError(
7060 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7061 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7062 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007063 }
7064 return skip;
7065}
7066
7067bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007068 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7069 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7070 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7071 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007072 uint32_t width, uint32_t height, uint32_t depth) const {
7073 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007074 // RayGen
7075 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7076 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7077 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007078 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007079 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7080 0) {
7081 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7082 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7083 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7084 }
7085 // Callable
7086 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7087 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7088 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7089 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007090 }
7091 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7092 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7093 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007094 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7095 }
7096 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7097 0) {
7098 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7099 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7100 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007101 }
7102 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007103 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7104 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7105 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7106 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007107 }
7108 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7109 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007110 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7111 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007112 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007113 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7114 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7115 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7116 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7117 }
sourav parmar83c31b12020-05-06 12:30:54 -07007118 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007119 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7120 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7121 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7122 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007123 }
7124 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7125 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7126 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007127 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7128 }
7129 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7130 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7131 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7132 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7133 }
7134 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007135 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007136 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7137 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7138 }
7139 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7140 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007141 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007142 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7143 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007144 }
7145
sourav parmarcd5fb182020-07-17 12:58:44 -07007146 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7147 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007148 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007149 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7150 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7151 }
7152
7153 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7154 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007155 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007156 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7157 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007158 }
7159 return skip;
7160}
7161
sourav parmarcd5fb182020-07-17 12:58:44 -07007162bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7163 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7164 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7165 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007166 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007167 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007168 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7169 skip |= LogError(
7170 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7171 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7172 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007173 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007174 // RayGen
7175 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7176 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7177 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007178 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007179 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7180 0) {
7181 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7182 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7183 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7184 }
7185 // Callabe
7186 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7187 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7188 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7189 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007190 }
7191 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7192 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007193 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7194 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7195 }
7196 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7197 0) {
7198 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7199 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7200 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007201 }
7202 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007203 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7204 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7205 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7206 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007207 }
7208 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7209 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007210 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7211 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007212 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007213 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7214 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7215 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7216 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7217 }
sourav parmar83c31b12020-05-06 12:30:54 -07007218 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007219 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7220 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7221 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7222 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007223 }
7224 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7225 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007226 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7227 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7228 }
7229 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7230 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7231 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7232 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007233 }
7234
sourav parmarcd5fb182020-07-17 12:58:44 -07007235 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7236 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7237 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007238 }
7239 return skip;
7240}
7241bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7242 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7243 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7244 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7245 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7246 uint32_t width, uint32_t height, uint32_t depth) const {
7247 bool skip = false;
7248 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7249 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7250 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7251 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7252 }
7253 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7254 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7255 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7256 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7257 }
7258 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7259 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7260 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7261 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7262 }
7263
7264 // hitShader
7265 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7266 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7267 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7268 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7269 }
7270 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7271 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7272 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7273 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7274 }
7275 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7276 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7277 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7278 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7279 }
7280
7281 // missShader
7282 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7283 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7284 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7285 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7286 }
7287 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7288 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7289 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7290 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7291 }
7292 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7293 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7294 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7295 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7296 }
7297
7298 // raygenShader
7299 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7300 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7301 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007302 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7303 }
7304 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7305 skip |=
7306 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7307 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7308 }
7309 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7310 skip |=
7311 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7312 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7313 }
7314 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7315 skip |=
7316 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7317 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007318 }
7319 return skip;
7320}
7321
sourav parmar83c31b12020-05-06 12:30:54 -07007322bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007323 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7324 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007325 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007326 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7327 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007328 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7329 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007330 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007331 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7332 }
7333 return skip;
7334}
7335
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007336bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7337 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007338 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007339 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007340
7341 if (!physical_device_features.multiViewport) {
7342 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007343 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7344 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007345 viewportCount);
7346 }
7347 } else { // multiViewport enabled
7348 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007349 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7350 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007351 ") must "
7352 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007353 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007354 }
7355 }
7356
7357 if (pViewports) {
7358 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7359 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007360 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007361 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007362 }
7363 }
7364
7365 return skip;
7366}
7367
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007368bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7369 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007370 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007371 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7372 return skip;
7373}
7374
7375bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7376 const VkViewport *pViewports) const {
7377 bool skip = false;
7378 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7379 return skip;
7380}
7381
7382bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7383 const VkRect2D *pScissors, bool is_ext) const {
7384 bool skip = false;
7385 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007386
7387 if (!physical_device_features.multiViewport) {
7388 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007389 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7390 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007391 ") must "
7392 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007393 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007394 }
7395 } else { // multiViewport enabled
7396 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007397 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7398 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007399 ") must "
7400 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007401 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007402 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007403 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7404 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007405 ") must "
7406 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007407 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007408 }
7409 }
7410
7411 if (pScissors) {
7412 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7413 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7414
7415 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007416 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7417 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007418 }
7419
7420 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007421 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7422 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007423 }
7424
7425 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7426 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007427 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7428 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7429 "] will overflow int32_t.",
7430 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007431 }
7432
7433 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7434 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007435 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7436 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7437 "] will overflow int32_t.",
7438 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7439 }
7440 }
7441 }
7442
7443 return skip;
7444}
7445
7446bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7447 const VkRect2D *pScissors) const {
7448 bool skip = false;
7449 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7450 return skip;
7451}
7452
7453bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7454 const VkRect2D *pScissors) const {
7455 bool skip = false;
7456 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7457 return skip;
7458}
7459
7460bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7461 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7462 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7463 bool is_2ext) const {
7464 bool skip = false;
7465 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7466 if (firstBinding >= device_limits.maxVertexInputBindings) {
7467 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7468 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7469 firstBinding, device_limits.maxVertexInputBindings);
7470 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7471 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7472 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7473 ") must be less than "
7474 "maxVertexInputBindings (%" PRIu32 ")",
7475 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7476 }
7477
7478 for (uint32_t i = 0; i < bindingCount; ++i) {
7479 if (pBuffers[i] == VK_NULL_HANDLE) {
7480 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7481 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7482 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7483 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7484 } else {
7485 if (pOffsets[i] != 0) {
7486 skip |=
7487 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7488 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7489 }
7490 }
7491 }
7492 if (pStrides) {
7493 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7494 skip |=
7495 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7496 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7497 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007498 }
7499 }
7500 }
7501
7502 return skip;
7503}
7504
7505bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7506 uint32_t bindingCount, const VkBuffer *pBuffers,
7507 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7508 const VkDeviceSize *pStrides) const {
7509 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007510 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7511 return skip;
7512}
Piers Daniell39842ee2020-07-10 16:42:33 -06007513
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007514bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7515 uint32_t bindingCount, const VkBuffer *pBuffers,
7516 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7517 const VkDeviceSize *pStrides) const {
7518 bool skip = false;
7519 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007520 return skip;
7521}
sourav parmarcd5fb182020-07-17 12:58:44 -07007522
7523bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7524 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7525 bool skip = false;
7526 for (uint32_t i = 0; i < infoCount; ++i) {
7527 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7528 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7529 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7530 }
7531 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7532 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7533 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7534 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7535 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7536 api_name);
7537 }
7538 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7539 skip |=
7540 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7541 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7542 }
7543 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7544 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7545 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7546 }
7547 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7548 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7549 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7550 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7551 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7552 api_name);
7553 }
7554 if (pInfos[i].pGeometries) {
7555 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7556 skip |= validate_ranged_enum(
7557 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7558 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7559 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7560 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007561 skip |= validate_struct_type(
7562 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7563 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7564 &(pInfos[i].pGeometries[j].geometry.triangles),
7565 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7566 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7567 skip |= validate_struct_pnext(
7568 api_name,
7569 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7570 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7571 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7572 skip |=
7573 validate_ranged_enum(api_name,
7574 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7575 ParameterName::IndexVector{i, j}),
7576 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7577 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7578 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7579 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7580 &pInfos[i].pGeometries[j].geometry.triangles,
7581 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7582 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7583 skip |= validate_ranged_enum(
7584 api_name,
7585 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7586 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7587 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7588
7589 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7590 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7591 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7592 }
7593 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7594 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7595 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7596 skip |=
7597 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7598 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7599 api_name);
7600 }
7601 }
7602 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7603 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7604 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7605 &pInfos[i].pGeometries[j].geometry.instances,
7606 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7607 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7608 skip |= validate_struct_type(
7609 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7610 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7611 &(pInfos[i].pGeometries[j].geometry.instances),
7612 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7613 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7614 skip |= validate_struct_pnext(
7615 api_name,
7616 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7617 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7618 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7619
7620 skip |= validate_bool32(api_name,
7621 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7622 ParameterName::IndexVector{i, j}),
7623 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7624 }
7625 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7626 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7627 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7628 &pInfos[i].pGeometries[j].geometry.aabbs,
7629 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7630 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7631 skip |= validate_struct_type(
7632 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7633 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7634 &(pInfos[i].pGeometries[j].geometry.aabbs),
7635 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7636 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7637 skip |= validate_struct_pnext(
7638 api_name,
7639 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7640 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7641 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7642 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7643 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7644 "(%s):stride must be less than or equal to 2^32-1", api_name);
7645 }
7646 }
7647 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7648 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7649 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7650 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7651 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7652 api_name);
7653 }
7654 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7655 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7656 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7657 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7658 "of elements of"
7659 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7660 api_name);
7661 }
7662 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7663 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7664 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7665 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7666 api_name);
7667 }
7668 }
7669 }
7670 }
7671 if (pInfos[i].ppGeometries != NULL) {
7672 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7673 skip |= validate_ranged_enum(
7674 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7675 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7676 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7677 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007678 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7679 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7680 &pInfos[i].ppGeometries[j]->geometry.triangles,
7681 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7682 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7683 skip |= validate_struct_type(
7684 api_name,
7685 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7686 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7687 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7688 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7689 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7690 skip |= validate_struct_pnext(
7691 api_name,
7692 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7693 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7694 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7695 skip |= validate_ranged_enum(api_name,
7696 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7697 ParameterName::IndexVector{i, j}),
7698 "VkFormat", AllVkFormatEnums,
7699 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7700 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7701 skip |= validate_ranged_enum(api_name,
7702 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7703 ParameterName::IndexVector{i, j}),
7704 "VkIndexType", AllVkIndexTypeEnums,
7705 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7706 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7707 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7708 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7709 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7710 }
7711 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7712 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7713 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7714 skip |=
7715 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7716 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7717 api_name);
7718 }
7719 }
7720 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7721 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7722 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7723 &pInfos[i].ppGeometries[j]->geometry.instances,
7724 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7725 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7726 skip |= validate_struct_type(
7727 api_name,
7728 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7729 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7730 &(pInfos[i].ppGeometries[j]->geometry.instances),
7731 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7732 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7733 skip |= validate_struct_pnext(
7734 api_name,
7735 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7736 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7737 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7738 skip |= validate_bool32(api_name,
7739 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7740 ParameterName::IndexVector{i, j}),
7741 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7742 }
7743 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7744 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7745 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7746 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7747 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7748 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7749 skip |= validate_struct_type(
7750 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7751 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7752 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7753 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7754 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7755 skip |= validate_struct_pnext(
7756 api_name,
7757 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7758 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7759 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7760 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7761 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7762 "(%s):stride must be less than or equal to 2^32-1", api_name);
7763 }
7764 }
7765 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7766 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7767 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7768 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7769 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7770 api_name);
7771 }
7772 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7773 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7774 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7775 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7776 "of elements of"
7777 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7778 api_name);
7779 }
7780 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7781 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7782 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7783 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7784 api_name);
7785 }
7786 }
7787 }
7788 }
7789 }
7790 return skip;
7791}
7792bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7793 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7794 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7795 bool skip = false;
7796 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7797 for (uint32_t i = 0; i < infoCount; ++i) {
7798 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7799 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7800 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7801 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7802 "scratchData.deviceAddress member must be a multiple of "
7803 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7804 }
7805 for (uint32_t k = 0; k < infoCount; ++k) {
7806 if (i == k) continue;
7807 bool found = false;
7808 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007809 skip |=
7810 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7811 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7812 ") of pInfos must "
7813 "not be "
7814 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7815 ") of pInfos.",
7816 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007817 found = true;
7818 }
7819 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007820 skip |=
7821 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7822 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7823 ") of pInfos must "
7824 "not be "
7825 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7826 ") of pInfos.",
7827 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007828 found = true;
7829 }
7830 if (found) break;
7831 }
7832 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7833 if (pInfos[i].pGeometries) {
7834 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7835 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7836 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7837 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7838 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7839 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7840 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7841 }
7842 } else {
7843 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7844 skip |=
7845 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7846 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7847 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7848 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7849 }
7850 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007851 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007852 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7853 skip |= LogError(
7854 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7855 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7856 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7857 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007858 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7859 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007860 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7861 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7862 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7863 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7864 }
7865 }
7866 } else if (pInfos[i].ppGeometries) {
7867 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7868 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7869 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7870 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7871 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7872 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7873 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7874 }
7875 } else {
7876 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7877 skip |=
7878 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7879 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7880 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7881 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7882 }
7883 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007884 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007885 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7886 skip |= LogError(
7887 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7888 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7889 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7890 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007891 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7892 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007893 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7894 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7895 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7896 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7897 }
7898 }
7899 }
7900 }
7901 }
7902 return skip;
7903}
7904
7905bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7906 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7907 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7908 const uint32_t *const *ppMaxPrimitiveCounts) const {
7909 bool skip = false;
7910 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7911 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007912 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007913 if (!ray_tracing_acceleration_structure_features ||
7914 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7915 skip |= LogError(
7916 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7917 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7918 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7919 }
7920 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007921 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7922 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7923 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7924 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7925 "scratchData.deviceAddress member must be a multiple of "
7926 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7927 }
7928 for (uint32_t k = 0; k < infoCount; ++k) {
7929 if (i == k) continue;
7930 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007931 skip |= LogError(
7932 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7933 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7934 ") "
7935 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7936 "any other element [%" PRIu32 ") of pInfos.",
7937 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007938 break;
7939 }
7940 }
7941 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7942 if (pInfos[i].pGeometries) {
7943 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7944 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7945 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7946 skip |= LogError(
7947 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7948 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7949 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7950 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7951 }
7952 } else {
7953 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7954 skip |= LogError(
7955 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7956 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7957 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7958 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7959 }
7960 }
7961 }
7962 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7963 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7964 skip |= LogError(
7965 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7966 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7967 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7968 }
7969 }
7970 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7971 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7972 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7973 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7974 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7975 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7976 }
7977 }
7978 } else if (pInfos[i].ppGeometries) {
7979 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7980 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7981 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7982 skip |= LogError(
7983 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7984 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7985 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7986 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7987 }
7988 } else {
7989 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7990 skip |= LogError(
7991 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7992 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7993 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7994 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7995 }
7996 }
7997 }
7998 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7999 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8000 skip |= LogError(
8001 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8002 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8003 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8004 }
8005 }
8006 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8007 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8008 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8009 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8010 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8011 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8012 }
8013 }
8014 }
8015 }
8016 }
8017 return skip;
8018}
8019
8020bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8021 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8022 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8023 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8024 bool skip = false;
8025 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8026 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008027 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008028 if (!ray_tracing_acceleration_structure_features ||
8029 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8030 skip |=
8031 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8032 "vkBuildAccelerationStructuresKHR: The "
8033 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8034 }
8035 for (uint32_t i = 0; i < infoCount; ++i) {
8036 for (uint32_t j = 0; j < infoCount; ++j) {
8037 if (i == j) continue;
8038 bool found = false;
8039 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008040 skip |=
8041 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8042 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8043 ") of pInfos must "
8044 "not be "
8045 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8046 ") of pInfos.",
8047 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008048 found = true;
8049 }
8050 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008051 skip |=
8052 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8053 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8054 ") of pInfos must "
8055 "not be "
8056 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8057 ") of pInfos.",
8058 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008059 found = true;
8060 }
8061 if (found) break;
8062 }
8063 }
8064 return skip;
8065}
8066
8067bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8068 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8069 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8070 bool skip = false;
8071 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8072 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008073 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8074 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008075 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8076 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008077 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008078 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8079 }
8080 if (pBuildInfo != nullptr) {
8081 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8082 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8083 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8084 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8085 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008086 }
8087 return skip;
8088}
sfricke-samsungecafb192021-01-17 08:21:14 -08008089
Piers Daniellcb6d8032021-04-19 18:51:26 -06008090bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8091 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8092 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8093 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8094 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008095 const auto *vertex_attribute_divisor_features =
8096 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8097
Piers Daniellcb6d8032021-04-19 18:51:26 -06008098 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8099 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8100 skip |=
8101 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8102 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8103 }
8104
8105 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8106 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8107 skip |= LogError(
8108 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8109 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8110 }
8111
8112 // VUID-vkCmdSetVertexInputEXT-binding-04793
8113 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8114 bool binding_found = false;
8115 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8116 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8117 binding_found = true;
8118 break;
8119 }
8120 }
8121 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008122 skip |= LogError(
8123 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8124 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008125 }
8126 }
8127
8128 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8129 if (vertexBindingDescriptionCount > 1) {
8130 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8131 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8132 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8133 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8134 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008135 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8136 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008137 }
8138 }
8139 }
8140 }
8141
8142 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8143 if (vertexAttributeDescriptionCount > 1) {
8144 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8145 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8146 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8147 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8148 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008149 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8150 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008151 }
8152 }
8153 }
8154 }
8155
8156 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8157 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8158 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008159 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8160 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8161 "].binding is greater than maxVertexInputBindings",
8162 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008163 }
8164
8165 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8166 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008167 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8168 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8169 "].stride is greater than maxVertexInputBindingStride",
8170 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008171 }
8172
8173 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8174 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8175 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8176 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008177 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8178 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008179 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8180 binding);
8181 }
8182
8183 if (pVertexBindingDescriptions[binding].divisor > 1) {
8184 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8185 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8186 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008187 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8188 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008189 "vertexAttributeInstanceRateDivisor is not enabled",
8190 binding);
8191 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008192 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008193 if (pVertexBindingDescriptions[binding].divisor >
8194 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008195 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8196 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8197 "].divisor is greater than maxVertexAttribDivisor",
8198 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008199 }
8200
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008201 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008202 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008203 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8204 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8205 "].divisor is greater than 1 but inputRate "
8206 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8207 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008208 }
8209 }
8210 }
8211 }
8212
8213 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008214 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008215 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008216 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8217 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8218 "].location is greater than maxVertexInputAttributes",
8219 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008220 }
8221
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008222 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008223 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008224 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8225 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8226 "].binding is greater than maxVertexInputBindings",
8227 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008228 }
8229
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008230 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008231 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008232 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8233 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8234 "].offset is greater than maxVertexInputAttributeOffset",
8235 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008236 }
8237
8238 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8239 VkFormatProperties properties;
8240 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8241 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8242 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008243 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8244 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008245 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8246 attribute);
8247 }
8248 }
8249
8250 return skip;
8251}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008252
8253bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8254 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8255 const void *pValues) const {
8256 bool skip = false;
8257 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8258 // Check that offset + size don't exceed the max.
8259 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8260 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008261 skip |=
8262 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8263 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8264 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008265 }
8266 if (size > max_push_constants_size - offset) {
8267 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008268 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8269 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008270 offset, size, max_push_constants_size);
8271 }
8272
8273 // size needs to be non-zero and a multiple of 4.
8274 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008275 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8276 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008277 }
8278
8279 // offset needs to be a multiple of 4.
8280 if ((offset & 0x3) != 0) {
8281 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008282 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008283 }
8284 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008285}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008286
8287bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8288 uint32_t srcCacheCount,
8289 const VkPipelineCache *pSrcCaches) const {
8290 bool skip = false;
8291 if (pSrcCaches) {
8292 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8293 if (pSrcCaches[index0] == dstCache) {
8294 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8295 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8296 report_data->FormatHandle(dstCache).c_str());
8297 break;
8298 }
8299 }
8300 }
8301 return skip;
8302}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008303
8304bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8305 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8306 uint32_t rangeCount,
8307 const VkImageSubresourceRange *pRanges) const {
8308 bool skip = false;
8309 if (!pColor) {
8310 skip |=
8311 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8312 }
8313 return skip;
8314}
8315
8316bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8317 const VkRenderPassBeginInfo *const rp_begin) const {
8318 bool skip = false;
8319 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8320 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8321 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008322 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008323 func_name, rp_begin->clearValueCount);
8324 }
8325 return skip;
8326}
8327
8328bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8329 VkSubpassContents) const {
8330 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8331 return skip;
8332}
8333
8334bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8335 const VkRenderPassBeginInfo *pRenderPassBegin,
8336 const VkSubpassBeginInfo *) const {
8337 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8338 return skip;
8339}
8340
8341bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8342 const VkSubpassBeginInfo *) const {
8343 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8344 return skip;
8345}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008346
8347bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8348 uint32_t firstDiscardRectangle,
8349 uint32_t discardRectangleCount,
8350 const VkRect2D *pDiscardRectangles) const {
8351 bool skip = false;
8352
8353 if (pDiscardRectangles) {
8354 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8355 const int64_t x_sum =
8356 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8357 if (x_sum > std::numeric_limits<int32_t>::max()) {
8358 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8359 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8360 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8361 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8362 }
8363
8364 const int64_t y_sum =
8365 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8366 if (y_sum > std::numeric_limits<int32_t>::max()) {
8367 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8368 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8369 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8370 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8371 }
8372 }
8373 }
8374
8375 return skip;
8376}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008377
8378bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8379 uint32_t queryCount, size_t dataSize, void *pData,
8380 VkDeviceSize stride, VkQueryResultFlags flags) const {
8381 bool skip = false;
8382
8383 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8384 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8385 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8386 }
8387
8388 return skip;
8389}
ziga-lunargcf340c42021-08-19 00:13:38 +02008390
8391bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8392 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8393 bool skip = false;
8394
8395 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8396 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8397 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8398 ") is not a multiple of 4.",
8399 pConditionalRenderingBegin->offset);
8400 }
8401
8402 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008403}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008404
8405bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8406 VkSurfaceKHR surface,
8407 uint32_t *pSurfaceFormatCount,
8408 VkSurfaceFormatKHR *pSurfaceFormats) const {
8409 bool skip = false;
8410 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8411 skip |= LogError(
8412 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8413 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8414 }
8415 return skip;
8416}
8417
8418bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8419 VkSurfaceKHR surface,
8420 uint32_t *pPresentModeCount,
8421 VkPresentModeKHR *pPresentModes) const {
8422 bool skip = false;
8423 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8424 skip |= LogError(
8425 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8426 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8427 }
8428 return skip;
8429}
8430
8431bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8432 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8433 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8434 bool skip = false;
8435 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8436 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8437 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8438 "VK_GOOGLE_surfaceless_query is not enabled.");
8439 }
8440 return skip;
8441}
8442
8443bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8444 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8445 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8446 bool skip = false;
8447 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8448 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8449 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8450 "VK_GOOGLE_surfaceless_query is not enabled.");
8451 }
8452 return skip;
8453}
8454
8455#ifdef VK_USE_PLATFORM_WIN32_KHR
8456bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8457 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8458 VkPresentModeKHR *pPresentModes) const {
8459 bool skip = false;
8460 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8461 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8462 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8463 "VK_GOOGLE_surfaceless_query is not enabled.");
8464 }
8465 return skip;
8466}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008467
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008468#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008469
8470bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8471 const char *func_name) const {
8472 bool skip = false;
8473
8474 if (pInfo && pInfo->pCreateInfo) {
8475 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8476 if (image_swapchain_create_info) {
8477 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8478 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8479 }
8480 }
8481
8482 return skip;
8483}
8484
8485bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8486 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8487 bool skip = false;
8488
8489 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8490
8491 return skip;
8492}
8493
8494bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8495 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8496 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8497 bool skip = false;
8498
8499 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8500
8501 return skip;
8502}