blob: 290908f770545dd2650f6d1fd032b0850cfb1cf5 [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
Tony-LunarGd29cc032022-05-13 14:38:27 -06002243 skip |= validate_required_pointer(
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002244 "vkCreateGraphicsPipelines",
Tony-LunarGd29cc032022-05-13 14:38:27 -06002245 ParameterName("pCreateInfos[%i].stage[%i].pName", ParameterName::IndexVector{i, stage_index}),
2246 create_info.pStages[stage_index].pName, "VUID-VkPipelineShaderStageCreateInfo-pName-parameter");
2247
2248 if (create_info.pStages[stage_index].pName) {
2249 skip |= validate_string(
2250 "vkCreateGraphicsPipelines",
2251 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2252 kVUID_Stateless_InvalidShaderStagesArray, create_info.pStages[stage_index].pName);
2253 }
ziga-lunargc6341372021-07-28 12:57:42 +02002254
2255 std::stringstream msg;
2256 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2257 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002258 &create_info.pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002259 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002260 }
2261
2262 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002263 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (create_info.pTessellationState != nullptr)) {
2264 skip |=
2265 validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2266 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2267 create_info.pTessellationState, VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
2268 false, kVUIDUndefined, "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002269
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002270 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002271 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2272
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002273 skip |= validate_struct_pnext(
2274 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002275 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002276 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2277 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2278 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2279 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002280
2281 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002282 create_info.pTessellationState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002283 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2284 }
2285
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002286 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pInputAssemblyState != nullptr)) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002287 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2288 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002289 create_info.pInputAssemblyState,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002290 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2291 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2292
2293 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002294 create_info.pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002295 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002296
2297 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002298 create_info.pInputAssemblyState->flags,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002299 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2300
2301 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2302 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002303 create_info.pInputAssemblyState->topology,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002304 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2305
2306 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002307 create_info.pInputAssemblyState->primitiveRestartEnable);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002308 }
2309
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002310 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (create_info.pVertexInputState != nullptr)) {
2311 auto const &vertex_input_state = create_info.pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002312
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002313 if (create_info.pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002314 skip |=
2315 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2316 "vkCreateGraphicsPipelines: pararameter "
2317 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2318 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002319 }
2320
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002321 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002322 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002323 skip |=
2324 validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2325 "VkPipelineVertexInputDivisorStateCreateInfoEXT", create_info.pVertexInputState->pNext, 1,
2326 allowed_structs_vk_pipeline_vertex_input_state_create_info, GeneratedVulkanHeaderVersion,
2327 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
2328 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002329 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2330 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002331 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002332 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2333 skip |=
2334 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2335 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002336 create_info.pVertexInputState->vertexBindingDescriptionCount,
2337 &create_info.pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002338 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2339
2340 skip |= validate_array(
2341 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2342 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2343 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2344 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2345
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002346 if (create_info.pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002347 for (uint32_t vertex_binding_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002348 vertex_binding_description_index < create_info.pVertexInputState->vertexBindingDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002349 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002350 skip |= validate_ranged_enum(
2351 "vkCreateGraphicsPipelines",
2352 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2353 AllVkVertexInputRateEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002354 create_info.pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index].inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002355 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2356 }
2357 }
2358
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002359 if (create_info.pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002360 for (uint32_t vertex_attribute_description_index = 0;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002361 vertex_attribute_description_index < create_info.pVertexInputState->vertexAttributeDescriptionCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002362 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002363 const VkFormat format =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002364 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002365 skip |= validate_ranged_enum(
2366 "vkCreateGraphicsPipelines",
2367 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2368 AllVkFormatEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002369 create_info.pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index].format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002370 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002371 if (FormatIsDepthOrStencil(format)) {
2372 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2373 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2374 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2375 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002376 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2377 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002378 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2379 "alignment, replace with a color format.",
2380 i, vertex_attribute_description_index, string_VkFormat(format));
2381 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002382 }
2383 }
2384
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002385 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002386 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2387 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002388 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2389 ") is "
2390 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002391 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002392 }
2393
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002394 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002395 skip |=
2396 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2397 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002398 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2399 ") is "
2400 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002401 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002402 }
2403
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002404 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002405 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2406 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002407 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2408 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002409 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2410 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002411 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2412 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002413 "(%" PRIu32 ") is not distinct.",
2414 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002415 }
2416 vertex_bindings.insert(vertex_bind_desc.binding);
2417
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002418 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2420 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002421 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2422 "].binding (%" PRIu32
2423 ") is "
2424 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002425 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002426 }
2427
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002428 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002429 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2430 "vkCreateGraphicsPipelines: parameter "
2431 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2432 "].stride (%" PRIu32
2433 ") is greater "
2434 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2435 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 }
2437 }
2438
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002439 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002440 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2441 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002442 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2443 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002444 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2445 "vkCreateGraphicsPipelines: parameter "
2446 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2447 "].location (%" PRIu32 ") is not distinct.",
2448 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002449 }
2450 attribute_locations.insert(vertex_attrib_desc.location);
2451
2452 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2453 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002454 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2455 "vkCreateGraphicsPipelines: parameter "
2456 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2457 "].binding (%" PRIu32
2458 ") does not exist "
2459 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2460 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002461 }
2462
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002463 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002464 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2465 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002466 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2467 "].location (%" PRIu32
2468 ") is "
2469 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002470 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002471 }
2472
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002473 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002474 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2475 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002476 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2477 "].binding (%" PRIu32
2478 ") is "
2479 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002480 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002481 }
2482
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002483 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002484 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2485 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002486 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2487 "].offset (%" PRIu32
2488 ") is "
2489 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002490 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491 }
2492 }
2493 }
2494
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002495 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2496 if (has_control && has_eval) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002497 if (create_info.pTessellationState == nullptr) {
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002498 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002499 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2500 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002501 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002502 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002503 i, i);
2504 } else {
2505 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2506 skip |= validate_struct_pnext(
2507 "vkCreateGraphicsPipelines",
2508 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002509 "VkPipelineTessellationDomainOriginStateCreateInfo", create_info.pTessellationState->pNext, 1,
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002510 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2511 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002512
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002513 skip |= validate_reserved_flags(
2514 "vkCreateGraphicsPipelines",
2515 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002516 create_info.pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002517
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002518 if (create_info.pTessellationState->patchControlPoints == 0 ||
2519 create_info.pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2520 skip |=
2521 LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2522 "vkCreateGraphicsPipelines: invalid parameter "
2523 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2524 ". patchControlPoints "
2525 "should be >0 and <=%" PRIu32 ".",
2526 i, create_info.pTessellationState->patchControlPoints, device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002527 }
2528 }
2529 }
2530
2531 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002532 if ((create_info.pRasterizationState != nullptr) &&
2533 (create_info.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2534 if (create_info.pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002535 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2536 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2537 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2538 "].pViewportState (=NULL) is not a valid pointer.",
2539 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002540 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002541 const auto &viewport_state = *create_info.pViewportState;
Petr Krausa6103552017-11-16 21:21:58 +01002542
2543 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002544 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2545 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2546 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2547 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002548 }
2549
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002550 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002551 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002552 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2553 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002554 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2555 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002556 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002557 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002559 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002560 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002561 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002562 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002563 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002564 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002565 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002566 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002567 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568
2569 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002570 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002571 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002572 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002574 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002575 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002576 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002577 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002578 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002579 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2580 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002581 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002582 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2583 const auto depth_clip_control_struct =
2584 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002585
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002586 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002587 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002588 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2589 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2590 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2591 ") is not 1.",
2592 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002593 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002595 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002596 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2597 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2598 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2599 ") is not 1.",
2600 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002601 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002602
Dave Houlton142c4cb2018-10-17 15:04:41 -06002603 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2604 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002605 skip |= LogError(
2606 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2607 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2608 "disabled, but pCreateInfos[%" PRIu32
2609 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2610 ") is not 1.",
2611 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002612 }
2613
Jeff Bolz9af91c52018-09-01 21:53:57 -05002614 if (shading_rate_image_struct &&
2615 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002616 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2617 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2618 "disabled, but pCreateInfos[%" PRIu32
2619 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2620 ") is neither 0 nor 1.",
2621 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002622 }
2623
Petr Krausa6103552017-11-16 21:21:58 +01002624 } else { // multiViewport enabled
2625 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002626 if (!has_dynamic_viewport_with_count) {
2627 skip |= LogError(
2628 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2629 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2630 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002631 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002632 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2633 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2634 "].pViewportState->viewportCount (=%" PRIu32
2635 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2636 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002637 } else if (has_dynamic_viewport_with_count) {
2638 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2639 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2640 "].pViewportState->viewportCount (=%" PRIu32
2641 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2642 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002643 }
Petr Krausa6103552017-11-16 21:21:58 +01002644
2645 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002646 if (!has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002647 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2648 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2649 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength";
Piers Daniell39842ee2020-07-10 16:42:33 -06002650 skip |= LogError(
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002651 device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002652 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2653 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002654 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002655 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2656 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2657 "].pViewportState->scissorCount (=%" PRIu32
2658 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2659 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002660 } else if (has_dynamic_scissor_with_count) {
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002661 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2662 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136"
2663 : "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380";
2664 skip |= LogError(device, vuid,
Piers Daniell39842ee2020-07-10 16:42:33 -06002665 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2666 "].pViewportState->scissorCount (=%" PRIu32
2667 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2668 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669 }
2670 }
2671
ziga-lunarg845883b2021-07-14 15:05:00 +02002672 if (!has_dynamic_scissor && viewport_state.pScissors) {
2673 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2674 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002675
2676 if (scissor.offset.x < 0) {
2677 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2678 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2679 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2680 scissor.offset.x, i, scissor_i);
2681 }
2682
2683 if (scissor.offset.y < 0) {
2684 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2685 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2686 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2687 scissor.offset.y, i, scissor_i);
2688 }
2689
ziga-lunarg845883b2021-07-14 15:05:00 +02002690 const int64_t x_sum =
2691 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2692 if (x_sum > std::numeric_limits<int32_t>::max()) {
2693 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2694 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2695 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2696 "] will overflow int32_t.",
2697 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2698 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002699
ziga-lunarg845883b2021-07-14 15:05:00 +02002700 const int64_t y_sum =
2701 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2702 if (y_sum > std::numeric_limits<int32_t>::max()) {
2703 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2704 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2705 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2706 "] will overflow int32_t.",
2707 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2708 }
2709 }
2710 }
2711
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002712 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002713 skip |=
2714 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2715 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2716 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2717 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002718 }
2719
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002720 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002721 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2722 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2723 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2724 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2725 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002726 }
2727
ziga-lunarg0f0d6582022-03-13 16:17:40 +01002728 if (viewport_state.scissorCount != viewport_state.viewportCount) {
2729 if (!IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state) ||
2730 (!has_dynamic_viewport_with_count && !has_dynamic_scissor_with_count)) {
2731 const char *vuid = IsExtEnabled(device_extensions.vk_ext_extended_dynamic_state)
2732 ? "VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134"
2733 : "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220";
2734 skip |= LogError(
2735 device, vuid,
2736 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2737 ") is not identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2738 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
2739 }
Petr Krausa6103552017-11-16 21:21:58 +01002740 }
2741
Dave Houlton142c4cb2018-10-17 15:04:41 -06002742 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002743 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002744 skip |=
2745 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2746 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2747 ") must be zero or identical to pCreateInfos[%" PRIu32
2748 "].pViewportState->viewportCount (=%" PRIu32 ").",
2749 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002750 }
2751
Dave Houlton142c4cb2018-10-17 15:04:41 -06002752 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002753 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002754 skip |= LogError(
2755 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002756 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2757 "] "
2758 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2759 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2760 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002761 }
2762
Petr Krausa6103552017-11-16 21:21:58 +01002763 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002764 skip |= LogError(
2765 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002766 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2767 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002768 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2769 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002770 }
2771
2772 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002773 skip |= LogError(
2774 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002775 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2776 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002777 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2778 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002779 }
2780
Jeff Bolz3e71f782018-08-29 23:15:45 -05002781 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002782 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2783 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2784 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002785 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002786 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2787 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2788 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2789 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002790 }
2791
Jeff Bolz9af91c52018-09-01 21:53:57 -05002792 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002793 shading_rate_image_struct->viewportCount > 0 &&
2794 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002795 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002796 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002797 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002798 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2799 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002800 i, i);
2801 }
2802
Chris Mayer328d8212018-12-11 14:16:18 +01002803 if (vp_swizzle_struct) {
2804 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002805 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2806 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2807 " does "
2808 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2809 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002810 }
2811 }
2812
Petr Krausb3fcdb42018-01-09 22:09:09 +01002813 // validate the VkViewports
2814 if (!has_dynamic_viewport && viewport_state.pViewports) {
2815 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2816 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002817 const char *fn_name = "vkCreateGraphicsPipelines";
2818 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2819 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2820 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002822 }
2823 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002824
sfricke-samsung45996a42021-09-16 13:45:27 -07002825 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002826 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2827 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2828 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2829 "VK_NV_clip_space_w_scaling extension is not enabled.",
2830 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002831 }
2832
sfricke-samsung45996a42021-09-16 13:45:27 -07002833 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002834 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2835 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2836 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2837 "VK_EXT_discard_rectangles extension is not enabled.",
2838 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002839 }
2840
sfricke-samsung45996a42021-09-16 13:45:27 -07002841 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002842 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2843 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2844 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2845 "VK_EXT_sample_locations extension is not enabled.",
2846 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002847 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002848
sfricke-samsung45996a42021-09-16 13:45:27 -07002849 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002850 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2851 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2852 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2853 "VK_NV_scissor_exclusive extension is not enabled.",
2854 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002855 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002856
2857 if (coarse_sample_order_struct &&
2858 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2859 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2861 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2862 "] "
2863 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2864 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2865 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002866 }
2867
2868 if (coarse_sample_order_struct) {
2869 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002870 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002871 }
2872 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002873
2874 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2875 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002876 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2877 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2878 "] "
2879 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2880 ") "
2881 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2882 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002883 }
2884 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002885 skip |= LogError(
2886 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002887 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2888 "] "
2889 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2890 i);
2891 }
2892 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002893
2894 if (depth_clip_control_struct) {
2895 const auto *depth_clip_control_features =
2896 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2897 const bool enabled_depth_clip_control =
2898 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2899 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2900 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2901 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2902 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2903 "depthClipControl feature is not enabled. ",
2904 i);
2905 }
2906 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907 }
2908
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002909 const bool is_frag_out_graphics_lib =
2910 graphics_lib_info &&
2911 ((graphics_lib_info->flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) != 0);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002912 if (is_frag_out_graphics_lib && (create_info.pMultisampleState == nullptr)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002913 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002914 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2915 "].pRasterizationState->rasterizerDiscardEnable "
2916 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002917 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002918 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002919 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002920 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002921 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2922 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002923 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002924 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002925 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002926
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002927 // It is possible for pCreateInfos[i].pMultisampleState to be null when creating a graphics library
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002928 if (create_info.pMultisampleState) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002929 skip |= validate_struct_pnext(
2930 "vkCreateGraphicsPipelines",
2931 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002932 valid_struct_names, create_info.pMultisampleState->pNext, 4, valid_next_stypes,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002933 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2934 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002936 skip |= validate_reserved_flags(
2937 "vkCreateGraphicsPipelines",
2938 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002939 create_info.pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002941 skip |= validate_bool32(
2942 "vkCreateGraphicsPipelines",
2943 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002944 create_info.pMultisampleState->sampleShadingEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002945
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002946 skip |= validate_array(
2947 "vkCreateGraphicsPipelines",
2948 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2949 ParameterName::IndexVector{i}),
2950 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002951 create_info.pMultisampleState->rasterizationSamples, &create_info.pMultisampleState->pSampleMask, true,
2952 false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002953
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002954 skip |= validate_flags("vkCreateGraphicsPipelines",
2955 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples",
2956 ParameterName::IndexVector{i}),
2957 "VkSampleCountFlagBits", AllVkSampleCountFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002958 create_info.pMultisampleState->rasterizationSamples, kRequiredSingleBit,
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002959 "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002961 skip |= validate_bool32("vkCreateGraphicsPipelines",
2962 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable",
2963 ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002964 create_info.pMultisampleState->alphaToCoverageEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002966 skip |= validate_bool32(
2967 "vkCreateGraphicsPipelines",
2968 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002969 create_info.pMultisampleState->alphaToOneEnable);
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002970
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002971 if (create_info.pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002972 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
2973 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2974 "].pMultisampleState->sType must be "
2975 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002976 i);
John Zulauf7acac592017-11-06 11:15:53 -07002977 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002978 if (create_info.pMultisampleState->sampleShadingEnable == VK_TRUE) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002979 if (!physical_device_features.sampleRateShading) {
2980 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2981 "vkCreateGraphicsPipelines(): parameter "
2982 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
2983 i);
2984 }
2985 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2986 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002987 if (!in_inclusive_range(create_info.pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002988 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002989
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07002990 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2991 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2992 "].pMultisampleState->minSampleShading.",
2993 i);
2994 }
John Zulauf7acac592017-11-06 11:15:53 -07002995 }
2996 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002997
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002998 const auto *line_state =
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07002999 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(create_info.pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003000
3001 if (line_state) {
3002 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
3003 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003004 if (create_info.pMultisampleState->alphaToCoverageEnable) {
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->alphaToCoverageEnable == 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->alphaToOneEnable) {
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->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003016 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003017 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003018 if (create_info.pMultisampleState->sampleShadingEnable) {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003019 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003020 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
3021 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003022 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003023 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003024 }
3025 }
3026 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
3027 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
3028 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003029 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003030 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
3031 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 "range [1,256].",
3033 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003034 }
3035 }
3036 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003037 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003038 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3039 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003040 skip |=
3041 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003042 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3043 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003044 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
3045 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003046 }
3047 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3048 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003049 skip |=
3050 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003051 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3052 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003053 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
3054 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003055 }
3056 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3057 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 skip |=
3059 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003060 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3061 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003062 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
3063 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003064 }
3065 if (line_state->stippledLineEnable) {
3066 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
3067 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003068 skip |=
3069 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003070 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3071 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003072 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
3073 "stippledRectangularLines feature.",
3074 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003075 }
3076 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
3077 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003078 skip |=
3079 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003080 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3081 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003082 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
3083 "stippledBresenhamLines feature.",
3084 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003085 }
3086 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
3087 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003088 skip |=
3089 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003090 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3091 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003092 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
3093 "stippledSmoothLines feature.",
3094 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003095 }
3096 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05003097 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003098 skip |=
3099 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003100 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3101 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003102 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
3103 "stippledRectangularLines and strictLines features.",
3104 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003105 }
3106 }
3107 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003108 }
3109
Petr Krause91f7a12017-12-14 20:57:36 +01003110 bool uses_color_attachment = false;
3111 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003112 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01003113 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003114 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003115 const auto subpasses_uses_it = renderpasses_states.find(create_info.renderPass);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003116 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01003117 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003118 if (subpasses_uses.subpasses_using_color_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003119 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003120 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003121 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(create_info.subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01003122 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003123 }
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003124 subpass_flags = subpasses_uses.subpasses_flags[create_info.subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01003125 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003126 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01003127 }
3128
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003129 if (create_info.pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003130 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003131 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003133 create_info.pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003134 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003135
Mike Schuchardt00e81452021-11-29 11:11:20 -08003136 skip |=
3137 validate_flags("vkCreateGraphicsPipelines",
3138 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
3139 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003140 create_info.pDepthStencilState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003141 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142
3143 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003144 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003145 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003146 create_info.pDepthStencilState->depthTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147
3148 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003149 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003150 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003151 create_info.pDepthStencilState->depthWriteEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003152
3153 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003154 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003155 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003156 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003157 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158
3159 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003160 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003162 create_info.pDepthStencilState->depthBoundsTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163
3164 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003165 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003166 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003167 create_info.pDepthStencilState->stencilTestEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168
3169 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003170 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003171 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003172 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003173 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003174
3175 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003176 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003177 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003178 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003179 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003180
3181 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003182 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003183 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003184 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003185 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003186
3187 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003188 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003189 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003190 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003191 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003192
3193 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003194 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003195 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003196 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003197 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003198
3199 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003200 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003201 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003202 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003203 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003204
3205 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003206 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003207 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003208 "VkStencilOp", AllVkStencilOpEnums, create_info.pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003209 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003210
3211 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003212 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003213 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003214 "VkCompareOp", AllVkCompareOpEnums, create_info.pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003215 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003216
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003217 if (create_info.pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003218 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003219 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3220 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003221 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3222 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003223 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003224
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003225 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003226 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3227 const auto *rasterization_order_attachment_access_feature =
3228 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3229 const bool rasterization_order_depth_attachment_access_feature_enabled =
3230 rasterization_order_attachment_access_feature &&
3231 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3232 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3233 skip |= LogError(
3234 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3235 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3236 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3237 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003238 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003239 }
3240
3241 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3242 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003243 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003244 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3245 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003246 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003247 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3248 }
3249 }
3250
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003251 if ((create_info.pDepthStencilState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003252 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3253 const auto *rasterization_order_attachment_access_feature =
3254 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3255 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3256 rasterization_order_attachment_access_feature &&
3257 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3258 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3259 skip |= LogError(
3260 device,
3261 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3262 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3263 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3264 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003265 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003266 }
3267
3268 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3269 skip |= LogError(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003270 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003271 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3272 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003273 string_VkPipelineDepthStencilStateCreateFlags(create_info.pDepthStencilState->flags).c_str(),
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003274 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3275 }
3276 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003277 }
3278
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003279 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003280 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3281 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003282
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003283 if (create_info.pColorBlendState != nullptr && uses_color_attachment) {
3284 skip |=
3285 validate_struct_type("vkCreateGraphicsPipelines",
3286 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3287 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3288 create_info.pColorBlendState, VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
3289 false, kVUIDUndefined, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003290
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003291 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003292 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003293 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003294 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT",
3295 create_info.pColorBlendState->pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003296 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003297 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3298 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003299
Mike Schuchardt00e81452021-11-29 11:11:20 -08003300 skip |= validate_flags("vkCreateGraphicsPipelines",
3301 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3302 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003303 create_info.pColorBlendState->flags, kOptionalFlags,
Mike Schuchardt00e81452021-11-29 11:11:20 -08003304 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003305
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003306 if ((create_info.pColorBlendState->flags &
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003307 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3308 const auto *rasterization_order_attachment_access_feature =
3309 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3310 const bool rasterization_order_color_attachment_access_feature_enabled =
3311 rasterization_order_attachment_access_feature &&
3312 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3313
3314 if (!rasterization_order_color_attachment_access_feature_enabled) {
3315 skip |= LogError(
3316 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3317 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3318 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3319 "VkPipelineColorBlendStateCreateInfo::flags == %s",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003320 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003321 }
3322
3323 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003324 skip |=
3325 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
3326 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3327 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3328 string_VkPipelineColorBlendStateCreateFlags(create_info.pColorBlendState->flags).c_str(),
3329 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003330 }
3331 }
3332
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003334 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003336 create_info.pColorBlendState->logicOpEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003337
3338 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003339 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003340 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3341 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003342 create_info.pColorBlendState->attachmentCount, &create_info.pColorBlendState->pAttachments, false, true,
3343 kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003344
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003345 if (create_info.pColorBlendState->pAttachments != NULL) {
3346 for (uint32_t attachment_index = 0; attachment_index < create_info.pColorBlendState->attachmentCount;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003347 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003348 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003349 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003350 ParameterName::IndexVector{i, attachment_index}),
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003351 create_info.pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003352
3353 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003354 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003355 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003356 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003357 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003358 create_info.pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003359 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003360
3361 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003362 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003363 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003364 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003365 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003366 create_info.pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003367 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003368
3369 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003370 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003371 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003372 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003373 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003374 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003375 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003376
3377 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003378 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003379 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003380 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003381 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003382 create_info.pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003383 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003384
3385 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003386 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003387 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003388 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003389 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003390 create_info.pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003391 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003392
3393 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003394 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003396 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003397 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003398 create_info.pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003399 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003400
3401 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003402 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003403 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003404 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003405 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003406 create_info.pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003407 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003408
3409 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3410 bool invalid = false;
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003411 switch (create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
ziga-lunarga283d022021-08-04 18:35:23 +02003412 case VK_BLEND_OP_ZERO_EXT:
3413 case VK_BLEND_OP_SRC_EXT:
3414 case VK_BLEND_OP_DST_EXT:
3415 case VK_BLEND_OP_SRC_OVER_EXT:
3416 case VK_BLEND_OP_DST_OVER_EXT:
3417 case VK_BLEND_OP_SRC_IN_EXT:
3418 case VK_BLEND_OP_DST_IN_EXT:
3419 case VK_BLEND_OP_SRC_OUT_EXT:
3420 case VK_BLEND_OP_DST_OUT_EXT:
3421 case VK_BLEND_OP_SRC_ATOP_EXT:
3422 case VK_BLEND_OP_DST_ATOP_EXT:
3423 case VK_BLEND_OP_XOR_EXT:
3424 case VK_BLEND_OP_INVERT_EXT:
3425 case VK_BLEND_OP_INVERT_RGB_EXT:
3426 case VK_BLEND_OP_LINEARDODGE_EXT:
3427 case VK_BLEND_OP_LINEARBURN_EXT:
3428 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3429 case VK_BLEND_OP_LINEARLIGHT_EXT:
3430 case VK_BLEND_OP_PINLIGHT_EXT:
3431 case VK_BLEND_OP_HARDMIX_EXT:
3432 case VK_BLEND_OP_PLUS_EXT:
3433 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3434 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3435 case VK_BLEND_OP_PLUS_DARKER_EXT:
3436 case VK_BLEND_OP_MINUS_EXT:
3437 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3438 case VK_BLEND_OP_CONTRAST_EXT:
3439 case VK_BLEND_OP_INVERT_OVG_EXT:
3440 case VK_BLEND_OP_RED_EXT:
3441 case VK_BLEND_OP_GREEN_EXT:
3442 case VK_BLEND_OP_BLUE_EXT:
3443 invalid = true;
3444 break;
3445 default:
3446 break;
3447 }
3448 if (invalid) {
3449 skip |= LogError(
3450 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3451 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3452 "].pColorBlendState->pAttachments[%" PRIu32
3453 "].colorBlendOp (%s) is not valid when "
3454 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3455 "VK_FALSE",
3456 i, attachment_index,
3457 string_VkBlendOp(
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003458 create_info.pColorBlendState->pAttachments[attachment_index].colorBlendOp));
ziga-lunarga283d022021-08-04 18:35:23 +02003459 }
3460 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003461 }
3462 }
3463
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003464 if (create_info.pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003465 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003466 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3467 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003468 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3469 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003470 }
3471
3472 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003473 if (create_info.pColorBlendState->logicOpEnable == VK_TRUE) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003474 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003475 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003476 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003477 AllVkLogicOpEnums, create_info.pColorBlendState->logicOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003478 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003479 }
3480 }
3481 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003482
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003483 const VkPipelineCreateFlags flags = create_info.flags;
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003484 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003485 if (create_info.basePipelineIndex != -1) {
3486 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003487 skip |=
3488 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003489 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3490 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003491 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003492 "and pCreateInfos->basePipelineIndex is not -1.",
3493 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003494 }
3495 }
3496
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003497 if (create_info.basePipelineHandle != VK_NULL_HANDLE) {
3498 if (create_info.basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003499 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003500 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3501 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003502 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003503 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3504 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003506 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003507 if (static_cast<uint32_t>(create_info.basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003508 skip |=
3509 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003510 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3511 ") must be a valid"
3512 "index into the pCreateInfos array, of size %" PRIu32 ".",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003513 i, create_info.basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003514 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003515 }
3516 }
3517
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003518 if (create_info.pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003519 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003520 if (create_info.pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003521 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003522 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3523 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3524 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3525 "if the extension VK_NV_fill_rectangle is not enabled.");
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003526 } else if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003527 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003528 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003529 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003530 "pCreateInfos[%" PRIu32
3531 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003532 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3533 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003534 }
3535 } else {
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003536 if ((create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3537 (create_info.pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
Chris Mayer840b2c42019-08-22 18:12:22 +02003538 (physical_device_features.fillModeNonSolid == false)) {
3539 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003540 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3541 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003542 "pCreateInfos[%" PRIu32
3543 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003544 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3545 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003546 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003547 }
Petr Kraus299ba622017-11-24 03:09:03 +01003548
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003549 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003550 (create_info.pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003551 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3552 "The line width state is static (pCreateInfos[%" PRIu32
3553 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3554 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3555 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
Nathaniel Cesario66ca3982022-03-01 15:51:11 -07003556 i, i, create_info.pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003557 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003558 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003559
3560 // Validate no flags not allowed are used
3561 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003562 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003563 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3564 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003565 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3566 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003567 }
Nathaniel Cesario81257cb2022-02-16 17:15:58 -07003568 if (!IsExtEnabled(device_extensions.vk_ext_graphics_pipeline_library) &&
3569 (flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003570 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
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_LIBRARY_BIT_KHR.",
3574 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003575 }
3576 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3577 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
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_ANY_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_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3584 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
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_CLOSEST_HIT_SHADERS_BIT_KHR.",
3588 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003589 }
3590 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3591 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
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_MISS_SHADERS_BIT_KHR.",
3595 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003596 }
3597 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3598 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
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_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3602 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003603 }
3604 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3605 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
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_TRIANGLES_BIT_KHR.",
3609 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003610 }
3611 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3612 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
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_SKIP_AABBS_BIT_KHR.",
3616 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003617 }
3618 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3619 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003620 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3621 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003622 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3623 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003624 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003625 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3626 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3627 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3628 "]->flags (0x%x) must not include "
3629 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3630 i, flags);
3631 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003632 }
3633 }
3634
3635 return skip;
3636}
3637
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003638bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3639 uint32_t createInfoCount,
3640 const VkComputePipelineCreateInfo *pCreateInfos,
3641 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003642 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003643 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003644 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003645 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003646 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003647 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003648 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003649 if (feedback_struct && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
3650 const auto feedback_count = feedback_struct->pipelineStageCreationFeedbackCount;
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06003651 if ((feedback_count != 0) && (feedback_count != 1)) {
Nathaniel Cesario29e12402022-03-14 09:45:23 -06003652 skip |= LogError(
3653 device, "VUID-VkComputePipelineCreateInfo-pipelineStageCreationFeedbackCount-06566",
3654 "vkCreateComputePipelines(): VkPipelineCreationFeedbackCreateInfo::pipelineStageCreationFeedbackCount (%" PRIu32
3655 ") is not 0 or 1 in pCreateInfos[%" PRIu32 "].",
3656 feedback_count, i);
3657 }
Peter Chen85366392019-05-14 15:20:11 -04003658 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003659
3660 // Make sure compute stage is selected
3661 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003662 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003663 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3664 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003665 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003666 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003667
sfricke-samsungeb549012021-04-16 01:25:51 -07003668 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3669 // Validate no flags not allowed are used
3670 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003671 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3672 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3673 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3674 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003675 }
3676 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3677 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
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_ANY_HIT_SHADERS_BIT_KHR.",
3681 i, flags);
3682 }
3683 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3684 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
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_CLOSEST_HIT_SHADERS_BIT_KHR.",
3688 i, flags);
3689 }
3690 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3691 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
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_MISS_SHADERS_BIT_KHR.",
3695 i, flags);
3696 }
3697 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3698 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
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_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3702 i, flags);
3703 }
3704 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3705 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
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_TRIANGLES_BIT_KHR.",
3709 i, flags);
3710 }
3711 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3712 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
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_SKIP_AABBS_BIT_KHR.",
3716 i, flags);
3717 }
3718 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3719 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003720 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3721 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003722 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3723 i, flags);
3724 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003725 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3726 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003727 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3728 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003729 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3730 i, flags);
3731 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003732 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3733 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003734 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3735 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003736 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3737 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003738 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003739 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3740 if (pCreateInfos[i].basePipelineIndex != -1) {
3741 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3742 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3743 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3744 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3745 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3746 i);
3747 }
3748 }
3749
3750 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3751 if (pCreateInfos[i].basePipelineIndex != -1) {
3752 skip |= LogError(
3753 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3754 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3755 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3756 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3757 i);
3758 }
3759 } else {
3760 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3761 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3762 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3763 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3764 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3765 }
3766 }
3767 }
ziga-lunargc6341372021-07-28 12:57:42 +02003768
3769 std::stringstream msg;
3770 msg << "pCreateInfos[%" << i << "].stage";
3771 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003772 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003773 return skip;
3774}
3775
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003776bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003777 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003778 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003779
3780 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003781 const auto &features = physical_device_features;
3782 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003783
John Zulauf71968502017-10-26 13:51:15 -06003784 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3785 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003786 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3787 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3788 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3789 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003790 }
3791
3792 // Anistropy cannot be enabled in sampler unless enabled as a feature
3793 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003794 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3795 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3796 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003797 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003798 }
John Zulauf71968502017-10-26 13:51:15 -06003799
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003800 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3801 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003802 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3803 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3804 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3805 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003806 }
3807 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003808 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3809 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3810 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3811 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003812 }
3813 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003814 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3815 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3816 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3817 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003818 }
3819 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3820 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3821 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3822 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003823 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3824 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3825 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3826 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3827 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3828 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003829 }
3830 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003831 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3832 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3833 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003834 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003835 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003836 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3837 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3838 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003839 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003840 }
3841
3842 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003843 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003844 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003845 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3846 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003847 if (sampler_reduction != nullptr) {
3848 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003849 skip |= LogError(device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3850 "vkCreateSampler(): copmareEnable is true so the sampler reduction mode must be "
3851 "VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
sfricke-samsung85252fb2020-05-08 20:44:06 -07003852 }
3853 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003854 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003855 if (sampler_reduction && sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
sjfricke751b7092022-04-12 21:49:37 +09003856 if (!IsExtEnabled(device_extensions.vk_ext_sampler_filter_minmax)) {
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003857 skip |= LogError(device, "VUID-VkSamplerCreateInfo-pNext-06726",
sjfricke751b7092022-04-12 21:49:37 +09003858 "vkCreateSampler(): sampler reduction mode is %s, but extension %s is not enabled.",
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003859 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3860 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
3861 }
ziga-lunarg01be97a2022-05-01 14:30:39 +02003862
3863 if (!IsExtEnabled(device_extensions.vk_ext_filter_cubic)) {
3864 if (pCreateInfo->magFilter == VK_FILTER_CUBIC_EXT || pCreateInfo->minFilter == VK_FILTER_CUBIC_EXT) {
3865 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01422",
3866 "vkCreateSampler(): sampler reduction mode is %s, magFilter is %s and minFilter is %s, but "
3867 "extension %s is not enabled.",
3868 string_VkSamplerReductionMode(sampler_reduction->reductionMode),
3869 string_VkFilter(pCreateInfo->magFilter), string_VkFilter(pCreateInfo->minFilter),
3870 VK_EXT_FILTER_CUBIC_EXTENSION_NAME);
3871 }
3872 }
ziga-lunarg9fc3e9b2022-04-11 12:04:56 +02003873 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003874
3875 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3876 // valid VkBorderColor value
3877 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3878 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3879 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003880 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3881 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003882 }
3883
John Zulauf275805c2017-10-26 15:34:49 -06003884 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003885 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003886 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3887 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003888 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3889 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3890 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003891 }
3892 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003893
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003894 // Check for valid Lod range
3895 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003896 skip |=
3897 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3898 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003899 }
3900
3901 // Check mipLodBias to device limit
3902 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003903 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3904 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3905 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003906 }
3907
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003908 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003909 if (sampler_conversion != nullptr) {
3910 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3911 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3912 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3913 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003914 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003915 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003916 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3917 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3918 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3919 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3920 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3921 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3922 }
3923 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003924
3925 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3926 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3927 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3928 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3929 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3930 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3931 }
3932 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3933 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3934 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3935 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3936 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3937 }
3938 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3939 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3940 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3941 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3942 pCreateInfo->minLod, pCreateInfo->maxLod);
3943 }
3944 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3945 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3946 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3947 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3948 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3949 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3950 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3951 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3952 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3953 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3954 }
3955 if (pCreateInfo->anisotropyEnable) {
3956 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3957 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3958 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3959 }
3960 if (pCreateInfo->compareEnable) {
3961 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3962 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3963 "pCreateInfo->compareEnable must be VK_FALSE");
3964 }
3965 if (pCreateInfo->unnormalizedCoordinates) {
3966 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3967 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3968 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3969 }
3970 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003971
Piers Daniell833b9492021-11-20 11:47:10 -07003972 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3973 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3974 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3975 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3976 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3977 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3978 }
3979 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3980 if (!custom_create_info) {
3981 skip |= LogError(
3982 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3983 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3984 "struct in pNext chain.\n",
3985 string_VkBorderColor(pCreateInfo->borderColor));
3986 } else {
3987 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3988 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3989 !FormatIsSampledInt(custom_create_info->format)) ||
3990 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3991 !FormatIsSampledFloat(custom_create_info->format)))) {
3992 skip |=
3993 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003994 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3995 "whose type does not match\n",
3996 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003997 ;
3998 }
3999 }
4000 }
4001
4002 const auto *border_color_component_mapping =
4003 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
4004 if (border_color_component_mapping) {
4005 const auto *border_color_swizzle_features =
4006 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
4007 bool border_color_swizzle_features_enabled =
4008 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
4009 if (!border_color_swizzle_features_enabled) {
4010 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
4011 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
4012 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06004013 }
4014 }
4015 }
4016
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004017 return skip;
4018}
4019
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004020bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
4021 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
4022 const char *func_name) const {
4023 bool skip = false;
4024
4025 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
4026 uint32_t mutable_type_count = 0;
4027 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
4028 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
4029 }
4030 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4031 if (mutable_type_count == 0) {
4032 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
4033 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4034 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
4035 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4036 "].descriptorTypeCount is 0.",
4037 func_name, i, i);
4038 }
4039 } else {
4040 if (mutable_type_count > 0) {
4041 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
4042 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
4043 "].descriptorType is %s, but "
4044 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4045 "].descriptorTypeCount is not 0.",
4046 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
4047 }
4048 }
4049 }
4050
4051 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
4052 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4053 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
4054 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
4055 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
4056 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4057 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
4058 func_name, j, k);
4059 break;
4060 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
4061 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
4062 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4063 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
4064 func_name, j, k);
4065 break;
4066 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
4067 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
4068 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4069 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
4070 func_name, j, k);
4071 break;
4072 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
4073 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
4074 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4075 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
4076 func_name, j, k);
4077 break;
4078 default:
4079 break;
4080 }
4081 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
4082 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
4083 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
4084 skip |=
4085 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
4086 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4087 "].pDescriptorTypes[%" PRIu32
4088 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
4089 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
4090 func_name, j, k, j, l,
4091 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
4092 }
4093 }
4094 }
4095 }
4096
4097 return skip;
4098}
4099
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004100bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
4101 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
4102 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004103 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004104 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004105
ziga-lunargfc6896f2021-10-15 18:46:12 +02004106 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4107 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4108 bool mutable_descriptor_type_features_enabled =
4109 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4110
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004111 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4112 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
4113 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
4114 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004115 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4116 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
4117 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
4118 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
4119 ++descriptor_index) {
4120 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07004121 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004122 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004123 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
4124 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004125 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004126 }
4127 }
4128 }
4129
4130 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
4131 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
4132 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004133 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004134 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4135 "].descriptorCount is not 0, "
4136 "pCreateInfo->pBindings[%" PRIu32
4137 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004138 "values.",
4139 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004140 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004141
4142 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
4143 (pCreateInfo->pBindings[i].stageFlags != 0) &&
4144 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004145 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
4146 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
4147 "].descriptorCount is not 0 and "
4148 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
4149 "].stageFlags "
4150 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
4151 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07004152 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004153
4154 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4155 if (!mutable_descriptor_type) {
4156 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
4157 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4158 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4159 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
4160 i);
4161 }
4162 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
4163 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
4164 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4165 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4166 "pImmutableSamplers is not NULL.",
4167 i);
4168 }
4169 if (!mutable_descriptor_type_features_enabled) {
4170 skip |= LogError(
4171 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
4172 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
4173 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
4174 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
4175 i);
4176 }
4177 }
4178
4179 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
4180 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4181 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
4182 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4183 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
4184 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
4185 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004186 }
4187 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02004188
4189 if (mutable_descriptor_type) {
4190 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
4191 "vkDescriptorSetLayoutCreateInfo");
4192 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004193 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02004194 if (pCreateInfo) {
4195 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
4196 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4197 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
4198 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4199 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
4200 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4201 }
4202 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
4203 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
4204 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
4205 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
4206 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
4207 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
4208 }
4209 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
4210 !mutable_descriptor_type_features_enabled) {
4211 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
4212 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
4213 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
4214 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
4215 }
4216 }
4217
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004218 return skip;
4219}
4220
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004221bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
4222 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004223 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004224 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4225 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4226 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004227 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4228 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004229}
4230
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004231bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4232 const VkWriteDescriptorSet *pDescriptorWrites,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004233 const bool isPushDescriptor) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004234 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004235
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004236 if (pDescriptorWrites != NULL) {
4237 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4238 // descriptorCount must be greater than 0
4239 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004240 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4241 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4242 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004243 }
4244
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004245 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004246 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004247 // dstSet must be a valid VkDescriptorSet handle
4248 skip |= validate_required_handle(vkCallingFunction,
4249 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4250 pDescriptorWrites[i].dstSet);
4251 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004252
4253 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4254 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4255 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4256 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4257 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004258 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004259 if (!isPushDescriptor) {
4260 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4261 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4262 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4263 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4264 // ObjectLifetimes::ValidateDescriptorWrite.
4265 skip |= LogError(
4266 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4267 "%s(): if pDescriptorWrites[%" PRIu32
4268 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4269 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4270 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4271 vkCallingFunction, i, i);
4272 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4273 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4274 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4275 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4276 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4277 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4278 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4279 "%s(): if pDescriptorWrites[%" PRIu32
4280 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4281 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4282 "].pImageInfo must not be NULL.",
4283 vkCallingFunction, i, i);
4284 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004285 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4286 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004287 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4288 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004289 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4290 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004291 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004292 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4293 ParameterName::IndexVector{i, descriptor_index}),
4294 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004295 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004296 }
4297 }
4298 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4299 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4300 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4301 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4302 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4303 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4304 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004305 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004306 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004307 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004308 "%s(): if pDescriptorWrites[%" PRIu32
4309 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004310 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4311 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004312 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004313 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004314 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004315 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004316 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004317 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004318 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4319 ++descriptor_index) {
4320 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4321 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4322 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004323 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004324 "%s(): if pDescriptorWrites[%" PRIu32
4325 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004326 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004327 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4328 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004329 }
4330 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004331 }
4332 }
4333 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4334 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004335 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004336 }
4337
4338 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4339 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004340 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004341 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4342 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004343 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004344 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004345 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004346 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004347 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004348 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004349 }
4350 }
4351 }
4352 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4353 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004354 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004355 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4356 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004357 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004358 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004359 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004360 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004361 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004362 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004363 }
4364 }
4365 }
4366 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004367 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4368 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004369 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004370 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004371 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4372 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4373 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4374 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004375 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004376 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4377 pDescriptorWrites[i].descriptorCount);
4378 }
4379 // further checks only if we have right structtype
4380 if (pnext_struct) {
4381 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4382 skip |= LogError(
4383 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004384 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4385 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004386 ".",
4387 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004388 }
sourav parmarbcee7512020-12-28 14:34:49 -08004389 if (pnext_struct->accelerationStructureCount == 0) {
4390 skip |= LogError(device,
4391 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004392 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004393 }
4394 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004395 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004396 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4397 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4398 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4399 skip |= LogError(device,
4400 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4401 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004402 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004403 }
4404 }
4405 }
sourav parmarbcee7512020-12-28 14:34:49 -08004406 }
4407 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004408 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004409 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4410 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4411 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4412 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004413 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004414 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4415 pDescriptorWrites[i].descriptorCount);
4416 }
4417 // further checks only if we have right structtype
4418 if (pnext_struct) {
4419 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4420 skip |= LogError(
4421 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004422 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4423 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004424 ".",
4425 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004426 }
sourav parmarbcee7512020-12-28 14:34:49 -08004427 if (pnext_struct->accelerationStructureCount == 0) {
4428 skip |= LogError(device,
4429 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004430 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004431 }
4432 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004433 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004434 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4435 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4436 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4437 skip |= LogError(device,
4438 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4439 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004440 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004441 }
4442 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004443 }
4444 }
4445 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004446 }
4447 }
4448 return skip;
4449}
4450
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004451bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4452 const VkWriteDescriptorSet *pDescriptorWrites,
4453 uint32_t descriptorCopyCount,
4454 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004455 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004456}
4457
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004458bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004459 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004460 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004461 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4462}
4463
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004464bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4465 const VkAllocationCallbacks *pAllocator,
4466 VkRenderPass *pRenderPass) const {
4467 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4468}
4469
Mike Schuchardt2df08912020-12-15 16:28:09 -08004470bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004471 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004472 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004473 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4474}
4475
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004476bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4477 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004478 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004479 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004480
4481 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4482 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4483 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004484 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4485 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004486 return skip;
4487}
4488
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004489bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004490 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004491 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004492
4493 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4494 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004495 bool cb_is_secondary;
4496 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004497 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004498 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4499 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004500
Tony-LunarG3c287f62020-12-17 12:39:49 -07004501 if (cb_is_secondary) {
4502 // Implicit VUs
4503 // validate only sType here; pointer has to be validated in core_validation
4504 const bool k_not_required = false;
4505 const char *k_no_vuid = nullptr;
4506 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4507 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004508 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4509 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004510
Tony-LunarG3c287f62020-12-17 12:39:49 -07004511 if (info) {
4512 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004513 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004514 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4515 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004516 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004517 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004518 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4519 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4520 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4521 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004522
Tony-LunarG3c287f62020-12-17 12:39:49 -07004523 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004524
Tony-LunarG3c287f62020-12-17 12:39:49 -07004525 // Explicit VUs
4526 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004527 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004528 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4529 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4530 cmd_name);
4531 }
4532
4533 if (physical_device_features.inheritedQueries) {
4534 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004535 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4536 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4537 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004538 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004539 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004540 }
4541
4542 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004543 skip |=
4544 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4545 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4546 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4547 } else { // !pipelineStatisticsQuery
4548 skip |=
4549 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4550 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004551 }
4552
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004553 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004554 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004555 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004556 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4557 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4558 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004559 commandBuffer,
4560 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004561 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4562 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4563 }
Petr Kraus139757b2019-08-15 17:19:33 +02004564 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004565
4566 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4567 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4568 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4569 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4570 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4571 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4572 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4573 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4574 }
Petr Kraus139757b2019-08-15 17:19:33 +02004575 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004576 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004577 return skip;
4578}
4579
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004580bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004581 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004582 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004583
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004584 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004585 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004586 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4587 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4588 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004589 }
4590 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004591 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4592 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4593 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004594 }
4595 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004596 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004597 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004598 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4599 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4600 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4601 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004602 }
4603 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004604
4605 if (pViewports) {
4606 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4607 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004608 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004609 skip |= manual_PreCallValidateViewport(
4610 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004611 }
4612 }
4613
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004614 return skip;
4615}
4616
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004617bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004618 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004619 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004621 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004622 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004623 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4624 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4625 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004626 }
4627 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004628 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4629 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4630 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004631 }
4632 } else { // multiViewport enabled
4633 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004634 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004635 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4636 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4637 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4638 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004639 }
4640 }
4641
Petr Kraus6260f0a2018-02-27 21:15:55 +01004642 if (pScissors) {
4643 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4644 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004645
Petr Kraus6260f0a2018-02-27 21:15:55 +01004646 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004647 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4648 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4649 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004650 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004651
Petr Kraus6260f0a2018-02-27 21:15:55 +01004652 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004653 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4654 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4655 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004656 }
4657
4658 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4659 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004660 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4661 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4662 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4663 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004664 }
4665
4666 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4667 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004668 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4669 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4670 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4671 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004672 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004673 }
4674 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004675
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004676 return skip;
4677}
4678
Jeff Bolz5c801d12019-10-09 10:38:45 -05004679bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004680 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004681
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004682 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004683 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4684 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004685 }
4686
4687 return skip;
4688}
4689
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004690bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004691 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004692 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004693
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004694 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004695 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004696 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4697 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004698 }
4699 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004700 skip |=
4701 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4702 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4703 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004704 }
4705 return skip;
4706}
4707
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004708bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004709 VkDeviceSize offset, uint32_t drawCount,
4710 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004711 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004712 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004713 skip |=
4714 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4715 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4716 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004717 }
4718 if (drawCount > device_limits.maxDrawIndirectCount) {
4719 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004720 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4721 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004722 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004723 }
4724 return skip;
4725}
4726
sfricke-samsungf692b972020-05-02 08:00:45 -07004727bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4728 VkDeviceSize countBufferOffset, bool khr) const {
4729 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004730 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004731 if (offset & 3) {
4732 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004733 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004734 }
4735
4736 if (countBufferOffset & 3) {
4737 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004738 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004739 countBufferOffset);
4740 }
4741 return skip;
4742}
4743
4744bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(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, false);
4749}
4750
4751bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4752 VkDeviceSize offset, VkBuffer countBuffer,
4753 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4754 uint32_t stride) const {
4755 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4756}
4757
4758bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4759 VkDeviceSize countBufferOffset, bool khr) const {
4760 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004761 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004762 if (offset & 3) {
4763 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004764 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004765 }
4766
4767 if (countBufferOffset & 3) {
4768 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004769 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004770 countBufferOffset);
4771 }
4772 return skip;
4773}
4774
4775bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4776 VkDeviceSize offset, VkBuffer countBuffer,
4777 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4778 uint32_t stride) const {
4779 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4780}
4781
4782bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4783 VkDeviceSize offset, VkBuffer countBuffer,
4784 VkDeviceSize countBufferOffset,
4785 uint32_t maxDrawCount, uint32_t stride) const {
4786 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4787}
4788
Tony-LunarG4490de42021-06-21 15:49:19 -06004789bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4790 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4791 uint32_t firstInstance, uint32_t stride) const {
4792 bool skip = false;
4793 if (stride & 3) {
4794 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4795 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4796 }
4797 if (drawCount && nullptr == pVertexInfo) {
4798 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4799 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4800 "one or more valid instances of VkMultiDrawInfoEXT structures");
4801 }
4802 return skip;
4803}
4804
4805bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4806 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4807 uint32_t instanceCount, uint32_t firstInstance,
4808 uint32_t stride, const int32_t *pVertexOffset) const {
4809 bool skip = false;
4810 if (stride & 3) {
4811 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4812 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4813 }
4814 if (drawCount && nullptr == pIndexInfo) {
4815 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4816 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4817 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4818 }
4819 return skip;
4820}
4821
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004822bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4823 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004824 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004825 bool skip = false;
4826 for (uint32_t rect = 0; rect < rectCount; rect++) {
4827 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004828 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004829 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004830 }
sfricke-samsung10867682020-04-25 02:20:39 -07004831 if (pRects[rect].rect.extent.width == 0) {
4832 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004833 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004834 }
4835 if (pRects[rect].rect.extent.height == 0) {
4836 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004837 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004838 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004839 }
4840 return skip;
4841}
4842
Andrew Fobel3abeb992020-01-20 16:33:22 -05004843bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4844 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4845 VkImageFormatProperties2 *pImageFormatProperties,
4846 const char *apiName) const {
4847 bool skip = false;
4848
4849 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004850 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004851 if (image_stencil_struct != nullptr) {
4852 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4853 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4854 // No flags other than the legal attachment bits may be set
4855 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4856 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004857 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4858 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4859 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4860 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4861 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004862 }
4863 }
4864 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004865 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4866 if (image_drm_format) {
4867 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4868 skip |= LogError(
4869 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4870 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4871 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4872 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4873 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004874 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4875 skip |= LogError(
4876 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4877 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4878 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4879 apiName, image_drm_format->queueFamilyIndexCount);
4880 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004881 } else {
4882 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4883 skip |= LogError(
4884 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4885 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4886 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4887 apiName);
4888 }
4889 }
4890 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4891 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4892 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4893 if (!format_list || format_list->viewFormatCount == 0) {
4894 skip |= LogError(
4895 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4896 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4897 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4898 apiName);
4899 }
4900 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004901 }
4902
4903 return skip;
4904}
4905
4906bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4907 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4908 VkImageFormatProperties2 *pImageFormatProperties) const {
4909 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4910 "vkGetPhysicalDeviceImageFormatProperties2");
4911}
4912
4913bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4914 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4915 VkImageFormatProperties2 *pImageFormatProperties) const {
4916 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4917 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4918}
4919
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004920bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4921 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4922 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4923 bool skip = false;
4924
4925 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4926 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4927 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4928 }
4929
4930 return skip;
4931}
4932
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004933bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4934 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4935 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4936 bool skip = false;
4937
4938 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4939 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4940 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4941 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4942 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4943 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4944 }
4945
ziga-lunarg42f884b2021-08-25 16:13:20 +02004946 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004947}
4948
sfricke-samsung3999ef62020-02-09 17:05:59 -08004949bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4950 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4951 bool skip = false;
4952
4953 if (pRegions != nullptr) {
4954 for (uint32_t i = 0; i < regionCount; i++) {
4955 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004956 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004957 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004958 }
4959 }
4960 }
4961 return skip;
4962}
4963
Jeff Leger178b1e52020-10-05 12:22:23 -04004964bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4965 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4966 bool skip = false;
4967
4968 if (pCopyBufferInfo->pRegions != nullptr) {
4969 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4970 if (pCopyBufferInfo->pRegions[i].size == 0) {
Tony-LunarGef035472021-11-02 10:23:33 -06004971 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004972 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004973 }
4974 }
4975 }
4976 return skip;
4977}
4978
Tony-LunarGef035472021-11-02 10:23:33 -06004979bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer,
4980 const VkCopyBufferInfo2 *pCopyBufferInfo) const {
4981 bool skip = false;
4982
4983 if (pCopyBufferInfo->pRegions != nullptr) {
4984 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4985 if (pCopyBufferInfo->pRegions[i].size == 0) {
4986 skip |= LogError(device, "VUID-VkBufferCopy2-size-01988",
4987 "vkCmdCopyBuffer2() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
4988 }
4989 }
4990 }
4991 return skip;
4992}
4993
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004994bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004995 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4996 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004997 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004998
4999 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005000 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
5001 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5002 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005003 }
5004
5005 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005006 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
5007 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
5008 "), must be greater than zero and less than or equal to 65536.",
5009 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005010 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005011 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
5012 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5013 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005014 }
5015 return skip;
5016}
5017
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005018bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005019 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005020 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005021
5022 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005023 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
5024 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
5025 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005026 }
5027
5028 if (size != VK_WHOLE_SIZE) {
5029 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005030 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005031 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
5032 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005033 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005034 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
5035 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005036 }
5037 }
5038 return skip;
5039}
5040
sfricke-samsunga1d00272021-03-10 21:37:41 -08005041bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005042 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005043
5044 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005045 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5046 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
5047 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
5048 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005049 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005050 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
5051 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
5052 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005053 }
5054
5055 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
5056 // queueFamilyIndexCount uint32_t values
5057 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005058 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005059 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005060 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08005061 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
5062 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005063 }
5064 }
5065
Dave Houlton413a6782018-05-22 13:01:54 -06005066 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005067 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005068
sfricke-samsunga1d00272021-03-10 21:37:41 -08005069 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
5070 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
5071 if (format_list_info) {
5072 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
5073 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
5074 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
5075 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005076 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
5077 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005078 func_name, viewFormatCount);
5079 }
5080
5081 // Using the first format, compare the rest of the formats against it that they are compatible
5082 for (uint32_t i = 1; i < viewFormatCount; i++) {
5083 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
5084 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
5085 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
5086 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005087 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
5088 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08005089 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
5090 string_VkFormat(format_list_info->pViewFormats[i]));
5091 }
5092 }
5093 }
5094
5095 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
5096 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
5097 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
5098 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
5099 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
5100 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
5101 func_name);
5102 } else {
5103 if (format_list_info == nullptr) {
5104 skip |= LogError(
5105 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5106 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
5107 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
5108 func_name);
5109 } else if (format_list_info->viewFormatCount == 0) {
5110 skip |= LogError(
5111 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5112 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
5113 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
5114 func_name);
5115 } else {
5116 bool found_base_format = false;
5117 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
5118 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
5119 found_base_format = true;
5120 break;
5121 }
5122 }
5123 if (!found_base_format) {
5124 skip |=
5125 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
5126 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
5127 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
5128 "pCreateInfo->imageFormat.",
5129 func_name);
5130 }
5131 }
5132 }
5133 }
5134 }
5135 return skip;
5136}
5137
5138bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
5139 const VkAllocationCallbacks *pAllocator,
5140 VkSwapchainKHR *pSwapchain) const {
5141 bool skip = false;
5142 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
5143 return skip;
5144}
5145
5146bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
5147 const VkSwapchainCreateInfoKHR *pCreateInfos,
5148 const VkAllocationCallbacks *pAllocator,
5149 VkSwapchainKHR *pSwapchains) const {
5150 bool skip = false;
5151 if (pCreateInfos) {
5152 for (uint32_t i = 0; i < swapchainCount; i++) {
5153 std::stringstream func_name;
5154 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
5155 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
5156 }
5157 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005158 return skip;
5159}
5160
Jeff Bolz5c801d12019-10-09 10:38:45 -05005161bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005162 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005163
5164 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005165 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06005166 if (present_regions) {
5167 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07005168 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06005169 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
5170 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07005171 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005172 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
5173 "extension swapchainCount is %i. These values must be equal.",
5174 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06005175 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005176 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08005177 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
5178 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005179 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
5180 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
5181 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06005182 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005183 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005184 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06005185 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005186 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005187 }
5188 }
5189
5190 return skip;
5191}
5192
sfricke-samsung5c1b7392020-12-13 22:17:15 -08005193bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
5194 const VkDisplayModeCreateInfoKHR *pCreateInfo,
5195 const VkAllocationCallbacks *pAllocator,
5196 VkDisplayModeKHR *pMode) const {
5197 bool skip = false;
5198
5199 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
5200 if (display_mode_parameters.visibleRegion.width == 0) {
5201 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
5202 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
5203 }
5204 if (display_mode_parameters.visibleRegion.height == 0) {
5205 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
5206 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
5207 }
5208 if (display_mode_parameters.refreshRate == 0) {
5209 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
5210 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
5211 }
5212
5213 return skip;
5214}
5215
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005216#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005217bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
5218 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
5219 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005220 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005221 bool skip = false;
5222
5223 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005224 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
5225 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005226 }
5227
5228 return skip;
5229}
5230#endif // VK_USE_PLATFORM_WIN32_KHR
5231
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005232static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
5233 bool partial_overlap = false;
5234
5235 static const std::vector<VkDescriptorType> all_descriptor_types = {
5236 VK_DESCRIPTOR_TYPE_SAMPLER,
5237 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5238 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
5239 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
5240 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
5241 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
5242 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5243 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5244 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5245 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5246 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5247 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5248 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5249 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5250 };
5251
5252 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5253 if (mutable_descriptor_type) {
5254 std::vector<VkDescriptorType> first_types, second_types;
5255 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5256 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5257 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5258 }
5259 } else {
5260 first_types = all_descriptor_types;
5261 }
5262 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5263 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5264 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5265 }
5266 } else {
5267 second_types = all_descriptor_types;
5268 }
5269
5270 bool complete_overlap = first_types.size() == second_types.size();
5271 bool disjoint = true;
5272 for (const auto first_type : first_types) {
5273 bool found = false;
5274 for (const auto second_type : second_types) {
5275 if (first_type == second_type) {
5276 found = true;
5277 break;
5278 }
5279 }
5280 if (found) {
5281 disjoint = false;
5282 } else {
5283 complete_overlap = false;
5284 }
5285 if (!disjoint && !complete_overlap) {
5286 partial_overlap = true;
5287 break;
5288 }
5289 }
5290 }
5291
5292 return partial_overlap;
5293}
5294
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005295bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005296 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005297 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005298 bool skip = false;
5299
5300 if (pCreateInfo) {
5301 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005302 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5303 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005304 }
5305
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005306 const auto *mutable_descriptor_type_features =
5307 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5308 bool mutable_descriptor_type_enabled =
5309 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5310
Petr Krausc8655be2017-09-27 18:56:51 +02005311 if (pCreateInfo->pPoolSizes) {
5312 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5313 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005314 skip |= LogError(
5315 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005316 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005317 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005318 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5319 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005320 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5321 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5322 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5323 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5324 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005325 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005326 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5327 skip |=
5328 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5329 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5330 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5331 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5332 i);
5333 }
5334 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5335 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5336 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5337 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5338 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5339 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5340 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5341 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5342 " and have sets which partially overlap.",
5343 i, j);
5344 }
5345 }
5346 }
5347 }
Petr Krausc8655be2017-09-27 18:56:51 +02005348 }
5349 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005350
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005351 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5352 skip |=
5353 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5354 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5355 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5356 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005357 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5358 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5359 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5360 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5361 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5362 }
Petr Krausc8655be2017-09-27 18:56:51 +02005363 }
5364
5365 return skip;
5366}
5367
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005368bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005369 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005370 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005371
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005372 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005373 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005374 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5375 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5376 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005377 }
5378
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005379 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005380 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005381 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5382 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5383 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005384 }
5385
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005386 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005387 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005388 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5389 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5390 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005391 }
5392
5393 return skip;
5394}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005395
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005396bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005397 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005398 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005399
5400 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005401 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5402 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005403 }
5404 return skip;
5405}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005406
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005407bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5408 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005409 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005410 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005411
5412 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005413 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005414 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005415 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5416 "vkCmdDispatch(): baseGroupX (%" PRIu32
5417 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5418 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005419 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005420 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5421 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5422 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5423 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005424 }
5425
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005426 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005427 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005428 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5429 "vkCmdDispatch(): baseGroupY (%" PRIu32
5430 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5431 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005432 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005433 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5434 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5435 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5436 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005437 }
5438
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005439 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005440 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005441 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5442 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5443 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5444 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005445 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005446 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5447 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5448 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5449 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005450 }
5451
5452 return skip;
5453}
5454
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005455bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5456 VkPipelineBindPoint pipelineBindPoint,
5457 VkPipelineLayout layout, uint32_t set,
5458 uint32_t descriptorWriteCount,
5459 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005460 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005461}
5462
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005463bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5464 uint32_t firstExclusiveScissor,
5465 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005466 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005467 bool skip = false;
5468
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005469 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005470 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005471 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005472 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5473 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5474 ") is not 0.",
5475 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005476 }
5477 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005478 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005479 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5480 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5481 ") is not 1.",
5482 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005483 }
5484 } else { // multiViewport enabled
5485 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005486 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005487 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5488 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5489 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5490 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005491 }
5492 }
5493
Jeff Bolz3e71f782018-08-29 23:15:45 -05005494 if (pExclusiveScissors) {
5495 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5496 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5497
5498 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005499 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5500 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5501 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005502 }
5503
5504 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005505 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5506 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5507 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005508 }
5509
5510 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5511 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005512 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5513 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5514 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5515 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005516 }
5517
5518 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5519 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005520 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5521 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5522 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5523 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005524 }
5525 }
5526 }
5527
5528 return skip;
5529}
5530
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005531bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5532 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005533 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005534 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005535 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5536 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5537 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5538 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5539 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5540 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005541 }
5542
5543 return skip;
5544}
5545
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005546bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5547 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005548 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005549 bool skip = false;
5550
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005551 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005552 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005553 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005554 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5555 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5556 ") is not 0.",
5557 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005558 }
5559 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005560 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005561 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5562 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5563 ") is not 1.",
5564 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005565 }
5566 }
5567
Jeff Bolz9af91c52018-09-01 21:53:57 -05005568 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005569 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005570 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5571 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5572 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5573 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005574 }
5575
5576 return skip;
5577}
5578
Jeff Bolz5c801d12019-10-09 10:38:45 -05005579bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5580 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5581 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005582 bool skip = false;
5583
Dave Houlton142c4cb2018-10-17 15:04:41 -06005584 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005585 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5586 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5587 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005588 }
5589
5590 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005591 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005592 }
5593
5594 return skip;
5595}
5596
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005597bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005598 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005599 bool skip = false;
5600
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005601 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005602 skip |= LogError(
5603 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005604 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5605 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005606 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005607 }
5608
5609 return skip;
5610}
5611
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005612bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5613 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005614 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005615 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005616 static const int condition_multiples = 0b0011;
5617 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005618 skip |= LogError(
5619 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005620 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005621 }
Lockee1c22882019-06-10 16:02:54 -06005622 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005623 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5624 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5625 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5626 stride);
Lockee1c22882019-06-10 16:02:54 -06005627 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005628 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005629 skip |= LogError(
5630 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005631 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5632 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005633 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005634 if (drawCount > device_limits.maxDrawIndirectCount) {
5635 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005636 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5637 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005638 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005639 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005640 return skip;
5641}
5642
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005643bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5644 VkDeviceSize offset, VkBuffer countBuffer,
5645 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005646 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005647 bool skip = false;
5648
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005649 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005650 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5651 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5652 "), is not a multiple of 4.",
5653 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005654 }
5655
5656 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005657 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5658 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5659 "), is not a multiple of 4.",
5660 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005661 }
5662
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005663 return skip;
5664}
5665
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005666bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005667 const VkAllocationCallbacks *pAllocator,
5668 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005669 bool skip = false;
5670
5671 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5672 if (pCreateInfo != nullptr) {
5673 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5674 // VkQueryPipelineStatisticFlagBits values
5675 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5676 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005677 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5678 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5679 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5680 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005681 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005682 if (pCreateInfo->queryCount == 0) {
5683 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5684 "vkCreateQueryPool(): queryCount must be greater than zero.");
5685 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005686 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005687 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005688}
5689
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005690bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5691 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005692 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005693 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5694 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005695}
5696
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005697void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005698 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5699 VkResult result) {
5700 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005701 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005702}
5703
Mike Schuchardt2df08912020-12-15 16:28:09 -08005704void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005705 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5706 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005707 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005708 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005709 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005710}
5711
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005712void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5713 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005714 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005715 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005716 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005717}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005718
Tony-LunarG3c287f62020-12-17 12:39:49 -07005719void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005720 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005721 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005722 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005723 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005724 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005725 }
5726 }
5727}
5728
5729void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005730 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005731 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005732 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5733 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5734 }
5735}
5736
5737void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005738 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005739 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005740 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5741 if (item->second == commandPool) {
5742 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005743 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005744 ++item;
5745 }
5746 }
5747}
5748
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005749bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005750 const VkAllocationCallbacks *pAllocator,
5751 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005752 bool skip = false;
5753
5754 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005755 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005756 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005757 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5758 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005759 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005760
5761 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005762 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005763 if (flags_info) {
5764 flags = flags_info->flags;
5765 }
5766
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005767 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005768 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005769 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005770 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5771 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005772 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005773 }
5774
5775#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005776 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005777#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005778 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5779 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005780#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005781 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005782#endif
5783
5784 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005785 skip |= LogError(
5786 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005787 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5788 }
5789 if (
5790#ifdef VK_USE_PLATFORM_WIN32_KHR
5791 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5792#endif
5793 (import_memory_fd && import_memory_fd->handleType) ||
5794#ifdef VK_USE_PLATFORM_ANDROID_KHR
5795 (import_memory_ahb && import_memory_ahb->buffer) ||
5796#endif
5797 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005798 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5799 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005800 }
5801 }
5802
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005803 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5804 if (export_memory) {
5805 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5806 if (export_memory_nv) {
5807 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5808 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5809 "VkExportMemoryAllocateInfoNV");
5810 }
5811#ifdef VK_USE_PLATFORM_WIN32_KHR
5812 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5813 if (export_memory_win32_nv) {
5814 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5815 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5816 "VkExportMemoryWin32HandleInfoNV");
5817 }
5818#endif
5819 }
5820
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005821 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005822 VkBool32 capture_replay = false;
5823 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005824 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005825 if (vulkan_12_features) {
5826 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5827 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5828 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005829 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005830 if (bda_features) {
5831 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5832 buffer_device_address = bda_features->bufferDeviceAddress;
5833 }
5834 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005835 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005836 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005837 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005838 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005839 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005840 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005841 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005842 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005843 }
5844 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005845 }
5846 return skip;
5847}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005848
Jason Macnak192fa0e2019-07-26 15:07:16 -07005849bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005850 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005851 bool skip = false;
5852
5853 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5854 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5855 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005856 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005857 } else {
5858 uint32_t vertex_component_size = 0;
5859 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5860 vertex_component_size = 4;
5861 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5862 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5863 vertex_component_size = 2;
5864 }
5865 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005866 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005867 }
5868 }
5869
5870 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5871 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005872 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005873 } else {
5874 uint32_t index_element_size = 0;
5875 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5876 index_element_size = 4;
5877 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5878 index_element_size = 2;
5879 }
5880 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005881 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005882 }
5883 }
5884 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5885 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005886 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005887 }
5888 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005889 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005890 }
5891 }
5892
5893 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005894 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005895 }
5896
5897 return skip;
5898}
5899
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005900bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5901 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005902 bool skip = false;
5903
5904 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005905 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005906 }
5907 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005908 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005909 }
5910
5911 return skip;
5912}
5913
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005914bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5915 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005916 bool skip = false;
5917 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005918 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005919 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005920 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005921 }
5922 return skip;
5923}
5924
5925bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005926 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005927 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005928 bool skip = false;
5929 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005930 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5931 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5932 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005933 }
5934 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005935 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5936 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5937 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005938 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005939 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5940 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5941 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5942 }
Jason Macnak5c954952019-07-09 15:46:12 -07005943 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5944 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005945 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5946 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5947 "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 -07005948 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005949 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005950 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005951 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5952 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005953 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5954 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005955 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005956 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005957 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5958 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5959 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005960 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005961 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005962 uint64_t total_triangle_count = 0;
5963 for (uint32_t i = 0; i < info.geometryCount; i++) {
5964 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005965
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005966 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005967
Jason Macnak5c954952019-07-09 15:46:12 -07005968 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5969 continue;
5970 }
5971 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5972 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005973 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005974 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5975 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5976 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005977 }
5978 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005979 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5980 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5981 for (uint32_t i = 1; i < info.geometryCount; i++) {
5982 const VkGeometryNV &geometry = info.pGeometries[i];
5983 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005984 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005985 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5986 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005987 "info.pGeometries[0].geometryType.",
5988 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005989 }
5990 }
5991 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005992 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5993 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5994 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5995 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5996 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5997 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5998 }
5999 }
6000 skip |=
6001 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06006002 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07006003 return skip;
6004}
6005
Ricardo Garciaa4935972019-02-21 17:43:18 +01006006bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
6007 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006008 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01006009 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01006010 if (pCreateInfo) {
6011 if ((pCreateInfo->compactedSize != 0) &&
6012 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006013 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
6014 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
6015 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
6016 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006017 }
Jason Macnak5c954952019-07-09 15:46:12 -07006018
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006019 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07006020 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01006021 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01006022 return skip;
6023}
Mike Schuchardt21638df2019-03-16 10:52:02 -07006024
Jeff Bolz5c801d12019-10-09 10:38:45 -05006025bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
6026 const VkAccelerationStructureInfoNV *pInfo,
6027 VkBuffer instanceData, VkDeviceSize instanceOffset,
6028 VkBool32 update, VkAccelerationStructureNV dst,
6029 VkAccelerationStructureNV src, VkBuffer scratch,
6030 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006031 bool skip = false;
6032
6033 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006034 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07006035 }
6036
6037 return skip;
6038}
6039
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006040bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
6041 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6042 VkAccelerationStructureKHR *pAccelerationStructure) const {
6043 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006044 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006045 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006046 if (!acceleration_structure_features ||
6047 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
6048 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
6049 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
6050 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006051 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006052 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
6053 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006054 (acceleration_structure_features &&
6055 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07006056 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07006057 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
6058 "vkCreateAccelerationStructureKHR(): If createFlags includes "
6059 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
6060 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07006061 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006062 if (pCreateInfo->deviceAddress &&
6063 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
6064 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
6065 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
6066 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
6067 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006068 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
6069 (acceleration_structure_features &&
6070 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
6071 skip |= LogError(
6072 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
6073 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
6074 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
6075 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006076 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
6077 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02006078 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
6079 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07006080 }
sourav parmar83c31b12020-05-06 12:30:54 -07006081 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006082 return skip;
6083}
6084
Jason Macnak5c954952019-07-09 15:46:12 -07006085bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
6086 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006087 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07006088 bool skip = false;
6089 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006090 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
6091 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07006092 }
6093 return skip;
6094}
6095
sourav parmarcd5fb182020-07-17 12:58:44 -07006096bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
6097 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
6098 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6099 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006100 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07006101 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07006102 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07006103 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006104 }
6105 return skip;
6106}
6107
Peter Chen85366392019-05-14 15:20:11 -04006108bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
6109 uint32_t createInfoCount,
6110 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
6111 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006112 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04006113 bool skip = false;
6114
6115 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006116 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6117 std::stringstream msg;
6118 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6119 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
6120 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006121 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04006122 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006123 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineStageCreationFeedbackCount-06651",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006124 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
6125 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
6126 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
6127 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04006128 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006129
6130 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006131 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006132 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6133 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6134 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6135 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
6136 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
6137 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6138 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6139 }
6140 }
6141
sourav parmarf4a78252020-04-10 13:04:21 -07006142 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
6143 skip |=
6144 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
6145 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
6146 }
6147 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
6148 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
6149 skip |=
6150 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
6151 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
6152 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
6153 }
6154 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6155 if (pCreateInfos[i].basePipelineIndex != -1) {
6156 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6157 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
6158 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
6159 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6160 "and pCreateInfos->basePipelineIndex is not -1.");
6161 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006162 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006163 skip |=
6164 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
6165 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
6166 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
6167 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
6168 "that element.");
6169 }
sourav parmarf4a78252020-04-10 13:04:21 -07006170 }
6171 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006172 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006173 skip |=
6174 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
6175 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6176 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
6177 "commands pCreateInfos parameter.");
6178 }
6179 } else {
6180 if (pCreateInfos[i].basePipelineIndex != -1) {
6181 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
6182 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
6183 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6184 }
6185 }
6186 }
6187 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
6188 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
6189 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
6190 }
6191 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
6192 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
6193 "vkCreateRayTracingPipelinesNV: flags must not include "
6194 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
6195 }
6196 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
6197 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
6198 "vkCreateRayTracingPipelinesNV: flags must not include "
6199 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
6200 }
6201 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
6202 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
6203 "vkCreateRayTracingPipelinesNV: flags must not include "
6204 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
6205 }
6206 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
6207 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
6208 "vkCreateRayTracingPipelinesNV: flags must not include "
6209 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
6210 }
6211 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6212 skip |= LogError(
6213 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
6214 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6215 }
6216 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6217 skip |= LogError(
6218 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
6219 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
6220 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006221 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
6222 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
6223 "vkCreateRayTracingPipelinesNV: flags must not include "
6224 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6225 }
6226 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6227 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
6228 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
6229 }
ziga-lunargdfffee42021-10-10 11:49:59 +02006230 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
6231 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
6232 "vkCreateRayTracingPipelinesNV: flags must not contain the "
6233 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
6234 }
Peter Chen85366392019-05-14 15:20:11 -04006235 }
6236
6237 return skip;
6238}
6239
sourav parmarcd5fb182020-07-17 12:58:44 -07006240bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
6241 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
6242 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006243 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006244 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006245 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6246 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6247 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006248 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006249 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006250 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6251 std::stringstream msg;
6252 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6253 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
aitor-lunargdbd9e652022-02-23 19:12:53 +01006254 &pCreateInfos[i].pStages[stage_index]);
ziga-lunargc6341372021-07-28 12:57:42 +02006255 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006256 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6257 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6258 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6259 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6260 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6261 }
6262 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6263 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6264 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6265 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6266 }
6267 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006268 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006269 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Nathaniel Cesario6a0ce2f2022-04-02 21:47:54 -06006270 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineStageCreationFeedbackCount-06652",
sourav parmarcd5fb182020-07-17 12:58:44 -07006271 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6272 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6273 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006274 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6275 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6276 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006277 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006278 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006279 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6280 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6281 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6282 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006283 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006284 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6285 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6286 }
6287 }
sourav parmarf4a78252020-04-10 13:04:21 -07006288 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006289 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6290 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006291 }
6292 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006293 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006294 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006295 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6296 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006297 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006298 }
6299 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6300 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6301 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006302 }
6303 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6304 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6305 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6306 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6307 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6308 skip |= LogError(
6309 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006310 "vkCreateRayTracingPipelinesKHR: If flags includes "
6311 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006312 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6313 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6314 "must not be VK_SHADER_UNUSED_KHR");
6315 }
6316 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6317 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6318 skip |= LogError(
6319 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006320 "vkCreateRayTracingPipelinesKHR: If flags includes "
6321 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006322 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6323 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6324 "element must not be VK_SHADER_UNUSED_KHR");
6325 }
6326 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006327 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6328 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6329 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6330 skip |= LogError(
6331 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6332 "vkCreateRayTracingPipelinesKHR: If "
6333 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6334 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6335 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6336 }
6337 }
sourav parmarf4a78252020-04-10 13:04:21 -07006338 }
6339 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6340 if (pCreateInfos[i].basePipelineIndex != -1) {
6341 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6342 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006343 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006344 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6345 "and pCreateInfos->basePipelineIndex is not -1.");
6346 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006347 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006348 skip |=
6349 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6350 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6351 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6352 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6353 "element.");
6354 }
sourav parmarf4a78252020-04-10 13:04:21 -07006355 }
6356 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006357 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006358 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006359 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006360 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6361 ") must be a valid into the calling"
6362 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006363 pCreateInfos[i].basePipelineIndex, createInfoCount);
6364 }
6365 } else {
6366 if (pCreateInfos[i].basePipelineIndex != -1) {
6367 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006368 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006369 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6370 }
6371 }
6372 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006373 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6374 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6375 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6376 "vkCreateRayTracingPipelinesKHR: If flags includes "
6377 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6378 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006379 }
6380 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6381 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6382 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6383 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6384 "pLibraryInfo and pLibraryInterface must be NULL.");
6385 }
6386 if (pCreateInfos[i].pLibraryInfo) {
6387 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6388 if (pCreateInfos[i].stageCount == 0) {
6389 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6390 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6391 "stageCount must not be 0.");
6392 }
6393 if (pCreateInfos[i].groupCount == 0) {
6394 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6395 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6396 "groupCount must not be 0.");
6397 }
6398 } else {
6399 if (pCreateInfos[i].pLibraryInterface == NULL) {
6400 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6401 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6402 "is greater than 0, its "
6403 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006404 }
6405 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006406 }
6407 if (pCreateInfos[i].pLibraryInterface) {
6408 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6409 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6410 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6411 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6412 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6413 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006414 }
6415 if (deferredOperation != VK_NULL_HANDLE) {
6416 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6417 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6418 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6419 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006420 }
6421 }
ziga-lunargdea76582021-09-17 14:38:08 +02006422 if (pCreateInfos[i].pDynamicState) {
6423 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6424 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6425 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6426 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6427 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6428 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6429 }
6430 }
6431 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006432 }
6433
6434 return skip;
6435}
6436
Mike Schuchardt21638df2019-03-16 10:52:02 -07006437#ifdef VK_USE_PLATFORM_WIN32_KHR
6438bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6439 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006440 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006441 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006442 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006443 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006444 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006445 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006446 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006447 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006448 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006449 skip |=
6450 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006451 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006452 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6453 skip |= validate_struct_type(
6454 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6455 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6456 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6457 if (pSurfaceInfo != NULL) {
6458 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6459 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6460 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6461
6462 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6463 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6464 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6465 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006466 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6467 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006468
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006469 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6470 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6471 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6472 "VK_GOOGLE_surfaceless_query is not enabled.");
6473 }
6474
Mike Schuchardt21638df2019-03-16 10:52:02 -07006475 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6476 }
6477 return skip;
6478}
6479#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006480
6481bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6482 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006483 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006484 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6485 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006486 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006487 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6488 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6489 }
6490 return skip;
6491}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006492
6493bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006494 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006495 bool skip = false;
6496
6497 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006498 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006499 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006500 }
6501
6502 return skip;
6503}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006504
6505bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006506 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006507 bool skip = false;
6508
6509 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006510 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6511 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006512 }
6513
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006514 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006515 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006516 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6517 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006518 }
6519
6520 return skip;
6521}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006522
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006523bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6524 uint32_t bindingCount, const VkBuffer *pBuffers,
6525 const VkDeviceSize *pOffsets) const {
6526 bool skip = false;
6527 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006528 skip |=
6529 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6530 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6531 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006532 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6533 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006534 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6535 ") must be less than "
6536 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006537 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6538 }
6539
Jeff Bolz165818a2020-05-08 11:19:03 -05006540 for (uint32_t i = 0; i < bindingCount; ++i) {
6541 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006542 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006543 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006544 skip |=
6545 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6546 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006547 } else {
6548 if (pOffsets[i] != 0) {
6549 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006550 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6551 "] is not 0",
6552 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006553 }
6554 }
6555 }
6556 }
6557
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006558 return skip;
6559}
6560
Mark Lobodzinski84988402019-09-11 15:27:30 -06006561bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006562 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006563 bool skip = false;
6564 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006565 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6566 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006567 }
6568 return skip;
6569}
6570
6571bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006572 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006573 bool skip = false;
6574 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006575 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6576 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006577 }
6578 return skip;
6579}
Petr Kraus3d720392019-11-13 02:52:39 +01006580
6581bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6582 VkSemaphore semaphore, VkFence fence,
6583 uint32_t *pImageIndex) const {
6584 bool skip = false;
6585
6586 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006587 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6588 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006589 }
6590
6591 return skip;
6592}
6593
6594bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6595 uint32_t *pImageIndex) const {
6596 bool skip = false;
6597
6598 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006599 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6600 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006601 }
6602
6603 return skip;
6604}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006605
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006606bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6607 uint32_t firstBinding, uint32_t bindingCount,
6608 const VkBuffer *pBuffers,
6609 const VkDeviceSize *pOffsets,
6610 const VkDeviceSize *pSizes) const {
6611 bool skip = false;
6612
6613 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6614 for (uint32_t i = 0; i < bindingCount; ++i) {
6615 if (pOffsets[i] & 3) {
6616 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6617 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6618 }
6619 }
6620
6621 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6622 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6623 "%s: The firstBinding(%" PRIu32
6624 ") index is greater than or equal to "
6625 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6626 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6627 }
6628
6629 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6630 skip |=
6631 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6632 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6633 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6634 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6635 }
6636
6637 for (uint32_t i = 0; i < bindingCount; ++i) {
6638 // pSizes is optional and may be nullptr.
6639 if (pSizes != nullptr) {
6640 if (pSizes[i] != VK_WHOLE_SIZE &&
6641 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6642 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6643 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6644 ") is not VK_WHOLE_SIZE and is greater than "
6645 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6646 cmd_name, i, pSizes[i]);
6647 }
6648 }
6649 }
6650
6651 return skip;
6652}
6653
6654bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6655 uint32_t firstCounterBuffer,
6656 uint32_t counterBufferCount,
6657 const VkBuffer *pCounterBuffers,
6658 const VkDeviceSize *pCounterBufferOffsets) const {
6659 bool skip = false;
6660
6661 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6662 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6663 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6664 "%s: The firstCounterBuffer(%" PRIu32
6665 ") index is greater than or equal to "
6666 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6667 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6668 }
6669
6670 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6671 skip |=
6672 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6673 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6674 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6675 cmd_name, firstCounterBuffer, counterBufferCount,
6676 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6677 }
6678
6679 return skip;
6680}
6681
6682bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6683 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6684 const VkBuffer *pCounterBuffers,
6685 const VkDeviceSize *pCounterBufferOffsets) const {
6686 bool skip = false;
6687
6688 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6689 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6690 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6691 "%s: The firstCounterBuffer(%" PRIu32
6692 ") index is greater than or equal to "
6693 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6694 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6695 }
6696
6697 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6698 skip |=
6699 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6700 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6701 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6702 cmd_name, firstCounterBuffer, counterBufferCount,
6703 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6704 }
6705
6706 return skip;
6707}
6708
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006709bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6710 uint32_t firstInstance, VkBuffer counterBuffer,
6711 VkDeviceSize counterBufferOffset,
6712 uint32_t counterOffset, uint32_t vertexStride) const {
6713 bool skip = false;
6714
6715 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006716 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6717 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6718 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6719 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006720 }
6721
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006722 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006723 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006724 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006725 }
6726
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006727 return skip;
6728}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006729
6730bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6731 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6732 const VkAllocationCallbacks *pAllocator,
6733 VkSamplerYcbcrConversion *pYcbcrConversion,
6734 const char *apiName) const {
6735 bool skip = false;
6736
6737 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006738 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006739 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006740 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006741 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6742 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006743 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006744 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006745 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006746
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006747#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006748 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006749 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006750#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006751 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006752#endif
6753
sfricke-samsung1a72f942020-07-25 12:09:18 -07006754 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006755
6756 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006757 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006758 const VkComponentMapping components = pCreateInfo->components;
6759 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6760 if (FormatIsXChromaSubsampled(format) == true) {
6761 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6762 skip |=
6763 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006764 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6765 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006766 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006767 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006768
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006769 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6770 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6771 skip |= LogError(
6772 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6773 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6774 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6775 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6776 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006777
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006778 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6779 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6780 skip |=
6781 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006782 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6783 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006784 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006785 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006786
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006787 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6788 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6789 skip |=
6790 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006791 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6792 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006793 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006794 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006795
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006796 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006797 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6798 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6799 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006800 skip |=
6801 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006802 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6803 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006804 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6805 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006806 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006807 }
6808
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006809 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6810 // Checks same VU multiple ways in order to give a more useful error message
6811 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6812 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6813 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6814 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6815 skip |= LogError(
6816 device, vuid,
6817 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6818 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6819 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6820 string_VkComponentSwizzle(components.b));
6821 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006822
sfricke-samsunged028b02021-09-06 23:14:51 -07006823 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6824 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006825 // 3 = no [a]
6826 // 2 = no [b,a]
6827 // 1 = no [g,b,a]
6828 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006829 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006830
sfricke-samsunged028b02021-09-06 23:14:51 -07006831 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6832 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006833 skip |= LogError(device, vuid,
6834 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6835 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6836 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6837 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006838 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006839 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6840 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6841 skip |= LogError(device, vuid,
6842 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6843 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6844 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6845 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6846 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006847 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006848 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6849 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6850 skip |= LogError(device, vuid,
6851 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6852 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6853 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6854 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6855 string_VkComponentSwizzle(components.b));
6856 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006857 }
6858 }
6859
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006860 return skip;
6861}
6862
6863bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6864 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6865 const VkAllocationCallbacks *pAllocator,
6866 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6867 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6868 "vkCreateSamplerYcbcrConversion");
6869}
6870
6871bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6872 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6873 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6874 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6875 "vkCreateSamplerYcbcrConversionKHR");
6876}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006877
6878bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6879 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6880 bool skip = false;
6881 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6882 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6883
6884 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006885 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6886 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6887 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6888 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6889 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006890 }
6891 return skip;
6892}
sourav parmara96ab1a2020-04-25 16:28:23 -07006893
6894bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006895 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006896 bool skip = false;
6897 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6898 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6899 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6900 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006901 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006902 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6903 skip |= LogError(
6904 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6905 "vkCopyAccelerationStructureToMemoryKHR: The "
6906 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6907 }
6908 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6909 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6910 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6911 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6912 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6913 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006914 return skip;
6915}
6916
6917bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6918 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6919 bool skip = false;
6920 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6921 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6922 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6923 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6924 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006925 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6926 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006927 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006928 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006929 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006930 return skip;
6931}
6932
6933bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6934 const char *api_name) const {
6935 bool skip = false;
6936 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6937 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6938 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6939 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6940 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6941 api_name);
6942 }
6943 return skip;
6944}
6945
6946bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006947 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006948 bool skip = false;
6949 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006950 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006951 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006952 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006953 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6954 "vkCopyAccelerationStructureKHR: The "
6955 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006956 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006957 return skip;
6958}
6959
6960bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6961 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6962 bool skip = false;
6963 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6964 return skip;
6965}
6966
6967bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006968 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006969 bool skip = false;
6970 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006971 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006972 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6973 }
6974 return skip;
6975}
6976
6977bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006978 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006979 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006980 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006981 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006982 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6983 skip |= LogError(
6984 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6985 "vkCopyMemoryToAccelerationStructureKHR: The "
6986 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006987 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006988 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6989 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006990 return skip;
6991}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006992
sourav parmara96ab1a2020-04-25 16:28:23 -07006993bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6994 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6995 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006996 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006997 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6998 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006999 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07007000 pInfo->src.deviceAddress);
7001 }
sourav parmar83c31b12020-05-06 12:30:54 -07007002 return skip;
7003}
7004bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
7005 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7006 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
7007 bool skip = false;
7008 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7009 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007010 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7011 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7012 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7013 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7014 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7015 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7016 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7017 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7018 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7019 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7020 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7021 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7022 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7023 }
sourav parmar83c31b12020-05-06 12:30:54 -07007024 }
7025 return skip;
7026}
7027bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
7028 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
7029 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
7030 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007031 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007032 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7033 skip |= LogError(
7034 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
7035 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
7036 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
7037 }
sourav parmar83c31b12020-05-06 12:30:54 -07007038 if (dataSize < accelerationStructureCount * stride) {
7039 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
7040 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007041 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07007042 dataSize, accelerationStructureCount, stride);
7043 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007044
sourav parmar83c31b12020-05-06 12:30:54 -07007045 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
7046 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
sfricke-samsungf91881c2022-03-31 01:12:00 -05007047 if (!IsExtEnabled(device_extensions.vk_khr_ray_tracing_maintenance1)) {
7048 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
7049 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7050 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7051 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7052 } else if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
7053 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR)) {
7054 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06742",
7055 "vkWriteAccelerationStructuresPropertiesKHR: queryType (%s) must be "
7056 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR or "
7057 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR or "
7058 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
7059 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.", string_VkQueryType(queryType));
7060 }
sourav parmar83c31b12020-05-06 12:30:54 -07007061 }
sfricke-samsungf91881c2022-03-31 01:12:00 -05007062
7063 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
7064 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007065 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
7066 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7067 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
7068 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7069 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007070 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07007071 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
7072 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7073 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
7074 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7075 stride);
sfricke-samsungf91881c2022-03-31 01:12:00 -05007076 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR) {
7077 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06731",
7078 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7079 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR,"
7080 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7081 stride);
7082 } else if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
7083 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-06733",
7084 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
7085 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR,"
7086 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
7087 stride);
sourav parmar83c31b12020-05-06 12:30:54 -07007088 }
7089 }
sourav parmar83c31b12020-05-06 12:30:54 -07007090 return skip;
7091}
7092bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
7093 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
7094 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007095 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007096 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
7097 skip |= LogError(
7098 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
7099 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
7100 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07007101 }
7102 return skip;
7103}
7104
7105bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07007106 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7107 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
7108 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7109 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07007110 uint32_t width, uint32_t height, uint32_t depth) const {
7111 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07007112 // RayGen
7113 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7114 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
7115 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007116 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007117 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7118 0) {
7119 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
7120 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7121 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7122 }
7123 // Callable
7124 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7125 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
7126 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7127 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007128 }
7129 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7130 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
7131 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007132 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7133 }
7134 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7135 0) {
7136 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
7137 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7138 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007139 }
7140 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007141 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7142 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
7143 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7144 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007145 }
7146 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7147 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007148 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
7149 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07007150 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007151 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7152 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
7153 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7154 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7155 }
sourav parmar83c31b12020-05-06 12:30:54 -07007156 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007157 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7158 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
7159 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
7160 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07007161 }
7162 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7163 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
7164 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07007165 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7166 }
7167 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7168 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
7169 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7170 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7171 }
7172 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
Mike Schuchardt840f1252022-05-11 11:31:25 -07007173 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03641",
sourav parmarcd5fb182020-07-17 12:58:44 -07007174 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
7175 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
7176 }
7177 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
7178 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007179 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03638",
sourav parmarcd5fb182020-07-17 12:58:44 -07007180 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
7181 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07007182 }
7183
sourav parmarcd5fb182020-07-17 12:58:44 -07007184 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
7185 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007186 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03639",
sourav parmarcd5fb182020-07-17 12:58:44 -07007187 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
7188 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
7189 }
7190
7191 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
7192 skip |=
Mike Schuchardt840f1252022-05-11 11:31:25 -07007193 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03640",
sourav parmarcd5fb182020-07-17 12:58:44 -07007194 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
7195 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07007196 }
7197 return skip;
7198}
7199
sourav parmarcd5fb182020-07-17 12:58:44 -07007200bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
7201 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
7202 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
7203 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007204 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007205 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007206 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7207 skip |= LogError(
7208 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
7209 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7210 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07007211 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007212 // RayGen
7213 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
7214 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
7215 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07007216 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007217 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7218 0) {
7219 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
7220 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
7221 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7222 }
7223 // Callabe
7224 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7225 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
7226 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
7227 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007228 }
7229 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7230 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07007231 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
7232 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7233 }
7234 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
7235 0) {
7236 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
7237 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
7238 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007239 }
7240 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007241 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7242 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
7243 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
7244 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007245 }
7246 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7247 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07007248 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
7249 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07007250 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007251 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7252 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
7253 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
7254 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
7255 }
sourav parmar83c31b12020-05-06 12:30:54 -07007256 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07007257 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
7258 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
7259 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
7260 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007261 }
7262 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
7263 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07007264 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
7265 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
7266 }
7267 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
7268 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
7269 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
7270 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07007271 }
7272
sourav parmarcd5fb182020-07-17 12:58:44 -07007273 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7274 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7275 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007276 }
7277 return skip;
7278}
sfricke-samsungf91881c2022-03-31 01:12:00 -05007279
7280bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer,
7281 VkDeviceAddress indirectDeviceAddress) const {
7282 bool skip = false;
7283 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7284 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
7285 skip |= LogError(
Mike Schuchardtac73fbe2022-05-24 10:37:52 -07007286 device, "VUID-vkCmdTraceRaysIndirect2KHR-rayTracingPipelineTraceRaysIndirect2-03637",
sfricke-samsungf91881c2022-03-31 01:12:00 -05007287 "vkCmdTraceRaysIndirect2KHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
7288 "feature must be enabled.");
7289 }
7290
7291 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7292 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03634",
7293 "vkCmdTraceRaysIndirect2KHR: indirectDeviceAddress must be a multiple of 4.");
7294 }
7295 return skip;
7296}
7297
sourav parmar83c31b12020-05-06 12:30:54 -07007298bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7299 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7300 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7301 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7302 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7303 uint32_t width, uint32_t height, uint32_t depth) const {
7304 bool skip = false;
7305 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7306 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7307 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7308 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7309 }
7310 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7311 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7312 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7313 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7314 }
7315 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7316 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7317 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7318 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7319 }
7320
7321 // hitShader
7322 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7323 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7324 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7325 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7326 }
7327 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7328 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7329 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7330 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7331 }
7332 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7333 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7334 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7335 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7336 }
7337
7338 // missShader
7339 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7340 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7341 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7342 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7343 }
7344 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7345 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7346 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7347 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7348 }
7349 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7350 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7351 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7352 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7353 }
7354
7355 // raygenShader
7356 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7357 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7358 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007359 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7360 }
7361 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7362 skip |=
7363 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7364 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7365 }
7366 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7367 skip |=
7368 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7369 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7370 }
7371 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7372 skip |=
7373 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7374 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007375 }
7376 return skip;
7377}
7378
sourav parmar83c31b12020-05-06 12:30:54 -07007379bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007380 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7381 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007382 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007383 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7384 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007385 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7386 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007387 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007388 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7389 }
7390 return skip;
7391}
7392
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007393bool StatelessValidation::ValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7394 const VkViewport *pViewports, bool is_ext) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007395 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007396 const char *api_call = is_ext ? "vkCmdSetViewportWithCountEXT" : "vkCmdSetViewportWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007397
7398 if (!physical_device_features.multiViewport) {
7399 if (viewportCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007400 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03395",
7401 "%s: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", api_call,
Piers Daniell39842ee2020-07-10 16:42:33 -06007402 viewportCount);
7403 }
7404 } else { // multiViewport enabled
7405 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007406 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCount-viewportCount-03394",
7407 "%s: viewportCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007408 ") must "
7409 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007410 api_call, viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007411 }
7412 }
7413
7414 if (pViewports) {
7415 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7416 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Piers Daniell39842ee2020-07-10 16:42:33 -06007417 skip |= manual_PreCallValidateViewport(
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007418 viewport, api_call, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Piers Daniell39842ee2020-07-10 16:42:33 -06007419 }
7420 }
7421
7422 return skip;
7423}
7424
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007425bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7426 const VkViewport *pViewports) const {
Piers Daniell39842ee2020-07-10 16:42:33 -06007427 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007428 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, true);
7429 return skip;
7430}
7431
7432bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7433 const VkViewport *pViewports) const {
7434 bool skip = false;
7435 skip = ValidateCmdSetViewportWithCount(commandBuffer, viewportCount, pViewports, false);
7436 return skip;
7437}
7438
7439bool StatelessValidation::ValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7440 const VkRect2D *pScissors, bool is_ext) const {
7441 bool skip = false;
7442 const char *api_call = is_ext ? "vkCmdSetScissorWithCountEXT" : "vkCmdSetScissorWithCount";
Piers Daniell39842ee2020-07-10 16:42:33 -06007443
7444 if (!physical_device_features.multiViewport) {
7445 if (scissorCount != 1) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007446 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03398",
7447 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007448 ") must "
7449 "be 1 when the multiViewport feature is disabled.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007450 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007451 }
7452 } else { // multiViewport enabled
7453 if (scissorCount == 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007454 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7455 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007456 ") must "
7457 "be great than zero.",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007458 api_call, scissorCount);
Piers Daniell39842ee2020-07-10 16:42:33 -06007459 } else if (scissorCount > device_limits.maxViewports) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007460 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-scissorCount-03397",
7461 "%s: scissorCount (=%" PRIu32
Piers Daniell39842ee2020-07-10 16:42:33 -06007462 ") must "
7463 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007464 api_call, scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06007465 }
7466 }
7467
7468 if (pScissors) {
7469 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7470 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7471
7472 if (scissor.offset.x < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007473 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", api_call,
7474 scissor_i, scissor.offset.x);
Piers Daniell39842ee2020-07-10 16:42:33 -06007475 }
7476
7477 if (scissor.offset.y < 0) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007478 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-x-03399", "%s: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", api_call,
7479 scissor_i, scissor.offset.y);
Piers Daniell39842ee2020-07-10 16:42:33 -06007480 }
7481
7482 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7483 if (x_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007484 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03400",
7485 "%s: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7486 "] will overflow int32_t.",
7487 api_call, scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007488 }
7489
7490 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7491 if (y_sum > INT32_MAX) {
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007492 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCount-offset-03401",
7493 "%s: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 ") of pScissors[%" PRIu32
7494 "] will overflow int32_t.",
7495 api_call, scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7496 }
7497 }
7498 }
7499
7500 return skip;
7501}
7502
7503bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7504 const VkRect2D *pScissors) const {
7505 bool skip = false;
7506 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, true);
7507 return skip;
7508}
7509
7510bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7511 const VkRect2D *pScissors) const {
7512 bool skip = false;
7513 skip = ValidateCmdSetScissorWithCount(commandBuffer, scissorCount, pScissors, false);
7514 return skip;
7515}
7516
7517bool StatelessValidation::ValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount,
7518 const VkBuffer *pBuffers, const VkDeviceSize *pOffsets,
7519 const VkDeviceSize *pSizes, const VkDeviceSize *pStrides,
7520 bool is_2ext) const {
7521 bool skip = false;
7522 const char *api_call = is_2ext ? "vkCmdBindVertexBuffers2EXT()" : "vkCmdBindVertexBuffers2()";
7523 if (firstBinding >= device_limits.maxVertexInputBindings) {
7524 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03355",
7525 "%s firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")", api_call,
7526 firstBinding, device_limits.maxVertexInputBindings);
7527 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7528 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-firstBinding-03356",
7529 "%s sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7530 ") must be less than "
7531 "maxVertexInputBindings (%" PRIu32 ")",
7532 api_call, firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7533 }
7534
7535 for (uint32_t i = 0; i < bindingCount; ++i) {
7536 if (pBuffers[i] == VK_NULL_HANDLE) {
7537 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
7538 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
7539 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04111",
7540 "%s required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", api_call, i);
7541 } else {
7542 if (pOffsets[i] != 0) {
7543 skip |=
7544 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pBuffers-04112",
7545 "%s pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32 "] is not 0", api_call, i, i);
7546 }
7547 }
7548 }
7549 if (pStrides) {
7550 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
7551 skip |=
7552 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2-pStrides-03362",
7553 "%s pStrides[%" PRIu32 "] (%" PRIu64 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7554 api_call, i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007555 }
7556 }
7557 }
7558
7559 return skip;
7560}
7561
7562bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7563 uint32_t bindingCount, const VkBuffer *pBuffers,
7564 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7565 const VkDeviceSize *pStrides) const {
7566 bool skip = false;
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007567 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, true);
7568 return skip;
7569}
Piers Daniell39842ee2020-07-10 16:42:33 -06007570
Tony-LunarG3f953ba2021-10-15 15:35:39 -06007571bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7572 uint32_t bindingCount, const VkBuffer *pBuffers,
7573 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7574 const VkDeviceSize *pStrides) const {
7575 bool skip = false;
7576 skip = ValidateCmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides, false);
Piers Daniell39842ee2020-07-10 16:42:33 -06007577 return skip;
7578}
sourav parmarcd5fb182020-07-17 12:58:44 -07007579
7580bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7581 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7582 bool skip = false;
7583 for (uint32_t i = 0; i < infoCount; ++i) {
7584 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7585 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7586 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7587 }
7588 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7589 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7590 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7591 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7592 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7593 api_name);
7594 }
7595 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7596 skip |=
7597 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7598 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7599 }
7600 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7601 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7602 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7603 }
7604 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7605 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7606 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7607 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7608 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7609 api_name);
7610 }
7611 if (pInfos[i].pGeometries) {
7612 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7613 skip |= validate_ranged_enum(
7614 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7615 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7616 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7617 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007618 skip |= validate_struct_type(
7619 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7620 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7621 &(pInfos[i].pGeometries[j].geometry.triangles),
7622 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7623 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7624 skip |= validate_struct_pnext(
7625 api_name,
7626 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7627 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7628 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7629 skip |=
7630 validate_ranged_enum(api_name,
7631 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7632 ParameterName::IndexVector{i, j}),
7633 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7634 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7635 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7636 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7637 &pInfos[i].pGeometries[j].geometry.triangles,
7638 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7639 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7640 skip |= validate_ranged_enum(
7641 api_name,
7642 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7643 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7644 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7645
7646 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7647 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7648 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7649 }
7650 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7651 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7652 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7653 skip |=
7654 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7655 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7656 api_name);
7657 }
7658 }
7659 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7660 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7661 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7662 &pInfos[i].pGeometries[j].geometry.instances,
7663 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7664 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7665 skip |= validate_struct_type(
7666 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7667 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7668 &(pInfos[i].pGeometries[j].geometry.instances),
7669 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7670 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7671 skip |= validate_struct_pnext(
7672 api_name,
7673 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7674 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7675 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7676
7677 skip |= validate_bool32(api_name,
7678 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7679 ParameterName::IndexVector{i, j}),
7680 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7681 }
7682 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7683 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7684 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7685 &pInfos[i].pGeometries[j].geometry.aabbs,
7686 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7687 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7688 skip |= validate_struct_type(
7689 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7690 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7691 &(pInfos[i].pGeometries[j].geometry.aabbs),
7692 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7693 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7694 skip |= validate_struct_pnext(
7695 api_name,
7696 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7697 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7698 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7699 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7700 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7701 "(%s):stride must be less than or equal to 2^32-1", api_name);
7702 }
7703 }
7704 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7705 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7706 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7707 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7708 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7709 api_name);
7710 }
7711 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7712 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7713 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7714 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7715 "of elements of"
7716 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7717 api_name);
7718 }
7719 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7720 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7721 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7722 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7723 api_name);
7724 }
7725 }
7726 }
7727 }
7728 if (pInfos[i].ppGeometries != NULL) {
7729 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7730 skip |= validate_ranged_enum(
7731 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7732 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7733 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7734 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007735 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7736 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7737 &pInfos[i].ppGeometries[j]->geometry.triangles,
7738 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7739 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7740 skip |= validate_struct_type(
7741 api_name,
7742 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7743 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7744 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7745 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7746 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7747 skip |= validate_struct_pnext(
7748 api_name,
7749 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7750 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7751 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7752 skip |= validate_ranged_enum(api_name,
7753 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7754 ParameterName::IndexVector{i, j}),
7755 "VkFormat", AllVkFormatEnums,
7756 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7757 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7758 skip |= validate_ranged_enum(api_name,
7759 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7760 ParameterName::IndexVector{i, j}),
7761 "VkIndexType", AllVkIndexTypeEnums,
7762 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7763 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7764 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7765 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7766 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7767 }
7768 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7769 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7770 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7771 skip |=
7772 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7773 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7774 api_name);
7775 }
7776 }
7777 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7778 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7779 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7780 &pInfos[i].ppGeometries[j]->geometry.instances,
7781 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7782 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7783 skip |= validate_struct_type(
7784 api_name,
7785 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7786 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7787 &(pInfos[i].ppGeometries[j]->geometry.instances),
7788 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7789 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7790 skip |= validate_struct_pnext(
7791 api_name,
7792 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7793 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7794 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7795 skip |= validate_bool32(api_name,
7796 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7797 ParameterName::IndexVector{i, j}),
7798 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7799 }
7800 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7801 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7802 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7803 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7804 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7805 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7806 skip |= validate_struct_type(
7807 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7808 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7809 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7810 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7811 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7812 skip |= validate_struct_pnext(
7813 api_name,
7814 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7815 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7816 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7817 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7818 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7819 "(%s):stride must be less than or equal to 2^32-1", api_name);
7820 }
7821 }
7822 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7823 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7824 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7825 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7826 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7827 api_name);
7828 }
7829 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7830 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7831 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7832 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7833 "of elements of"
7834 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7835 api_name);
7836 }
7837 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7838 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7839 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7840 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7841 api_name);
7842 }
7843 }
7844 }
7845 }
7846 }
7847 return skip;
7848}
7849bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7850 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7851 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7852 bool skip = false;
7853 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7854 for (uint32_t i = 0; i < infoCount; ++i) {
7855 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7856 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7857 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7858 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7859 "scratchData.deviceAddress member must be a multiple of "
7860 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7861 }
7862 for (uint32_t k = 0; k < infoCount; ++k) {
7863 if (i == k) continue;
7864 bool found = false;
7865 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007866 skip |=
7867 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7868 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7869 ") of pInfos must "
7870 "not be "
7871 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7872 ") of pInfos.",
7873 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007874 found = true;
7875 }
7876 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007877 skip |=
7878 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7879 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7880 ") of pInfos must "
7881 "not be "
7882 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7883 ") of pInfos.",
7884 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007885 found = true;
7886 }
7887 if (found) break;
7888 }
7889 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7890 if (pInfos[i].pGeometries) {
7891 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7892 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7893 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7894 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7895 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7896 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7897 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7898 }
7899 } else {
7900 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7901 skip |=
7902 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7903 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7904 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7905 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7906 }
7907 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007908 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007909 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7910 skip |= LogError(
7911 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7912 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7913 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7914 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007915 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7916 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007917 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7918 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7919 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7920 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7921 }
7922 }
7923 } else if (pInfos[i].ppGeometries) {
7924 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7925 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7926 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7927 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7928 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7929 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7930 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7931 }
7932 } else {
7933 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7934 skip |=
7935 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7936 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7937 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7938 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7939 }
7940 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007941 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007942 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7943 skip |= LogError(
7944 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7945 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7946 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7947 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007948 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7949 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007950 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7951 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7952 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7953 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7954 }
7955 }
7956 }
7957 }
7958 }
7959 return skip;
7960}
7961
7962bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7963 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7964 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7965 const uint32_t *const *ppMaxPrimitiveCounts) const {
7966 bool skip = false;
7967 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7968 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007969 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007970 if (!ray_tracing_acceleration_structure_features ||
7971 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7972 skip |= LogError(
7973 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7974 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7975 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7976 }
7977 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007978 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7979 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7980 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7981 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7982 "scratchData.deviceAddress member must be a multiple of "
7983 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7984 }
7985 for (uint32_t k = 0; k < infoCount; ++k) {
7986 if (i == k) continue;
7987 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007988 skip |= LogError(
7989 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7990 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7991 ") "
7992 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7993 "any other element [%" PRIu32 ") of pInfos.",
7994 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007995 break;
7996 }
7997 }
7998 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7999 if (pInfos[i].pGeometries) {
8000 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8001 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
8002 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8003 skip |= LogError(
8004 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8005 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8006 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8007 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8008 }
8009 } else {
8010 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
8011 skip |= LogError(
8012 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8013 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8014 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8015 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8016 }
8017 }
8018 }
8019 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8020 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
8021 skip |= LogError(
8022 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8023 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8024 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8025 }
8026 }
8027 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8028 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
8029 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8030 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8031 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8032 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8033 }
8034 }
8035 } else if (pInfos[i].ppGeometries) {
8036 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
8037 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
8038 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8039 skip |= LogError(
8040 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
8041 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8042 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
8043 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
8044 }
8045 } else {
8046 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
8047 skip |= LogError(
8048 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
8049 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8050 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
8051 "geometry.data->deviceAddress must be aligned to 16 bytes.");
8052 }
8053 }
8054 }
8055 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
8056 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
8057 skip |= LogError(
8058 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
8059 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
8060 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
8061 }
8062 }
8063 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
8064 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
8065 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
8066 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
8067 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
8068 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
8069 }
8070 }
8071 }
8072 }
8073 }
8074 return skip;
8075}
8076
8077bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
8078 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
8079 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
8080 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
8081 bool skip = false;
8082 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
8083 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008084 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07008085 if (!ray_tracing_acceleration_structure_features ||
8086 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
8087 skip |=
8088 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
8089 "vkBuildAccelerationStructuresKHR: The "
8090 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
8091 }
8092 for (uint32_t i = 0; i < infoCount; ++i) {
8093 for (uint32_t j = 0; j < infoCount; ++j) {
8094 if (i == j) continue;
8095 bool found = false;
8096 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008097 skip |=
8098 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
8099 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
8100 ") of pInfos must "
8101 "not be "
8102 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8103 ") of pInfos.",
8104 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008105 found = true;
8106 }
8107 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008108 skip |=
8109 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
8110 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
8111 ") of pInfos must "
8112 "not be "
8113 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
8114 ") of pInfos.",
8115 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07008116 found = true;
8117 }
8118 if (found) break;
8119 }
8120 }
8121 return skip;
8122}
8123
8124bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
8125 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
8126 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
8127 bool skip = false;
8128 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
8129 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07008130 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
8131 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
ziga-lunargbcfba982022-03-19 17:49:55 +01008132 if (!((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_TRUE) ||
8133 (ray_query_features && ray_query_features->rayQuery == VK_TRUE))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07008134 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01008135 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
8136 }
8137 if (pBuildInfo != nullptr) {
8138 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
8139 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
8140 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
8141 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
8142 }
sourav parmarcd5fb182020-07-17 12:58:44 -07008143 }
8144 return skip;
8145}
sfricke-samsungecafb192021-01-17 08:21:14 -08008146
Piers Daniellcb6d8032021-04-19 18:51:26 -06008147bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
8148 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
8149 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
8150 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
8151 bool skip = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06008152 const auto *vertex_attribute_divisor_features =
8153 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
8154
Piers Daniellcb6d8032021-04-19 18:51:26 -06008155 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
8156 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
8157 skip |=
8158 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
8159 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
8160 }
8161
8162 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
8163 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
8164 skip |= LogError(
8165 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
8166 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
8167 }
8168
8169 // VUID-vkCmdSetVertexInputEXT-binding-04793
8170 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
8171 bool binding_found = false;
8172 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8173 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
8174 binding_found = true;
8175 break;
8176 }
8177 }
8178 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008179 skip |= LogError(
8180 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
8181 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008182 }
8183 }
8184
8185 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
8186 if (vertexBindingDescriptionCount > 1) {
8187 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
8188 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
8189 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
8190 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
8191 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008192 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
8193 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008194 }
8195 }
8196 }
8197 }
8198
8199 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
8200 if (vertexAttributeDescriptionCount > 1) {
8201 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
8202 uint32_t location = pVertexAttributeDescriptions[attribute].location;
8203 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
8204 if (location == pVertexAttributeDescriptions[next_attribute].location) {
8205 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008206 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
8207 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008208 }
8209 }
8210 }
8211 }
8212
8213 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
8214 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
8215 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008216 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
8217 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8218 "].binding is greater than maxVertexInputBindings",
8219 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008220 }
8221
8222 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
8223 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008224 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
8225 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8226 "].stride is greater than maxVertexInputBindingStride",
8227 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008228 }
8229
8230 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
8231 if (pVertexBindingDescriptions[binding].divisor == 0 &&
8232 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
8233 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008234 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8235 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008236 "vertexAttributeInstanceRateZeroDivisor is not enabled",
8237 binding);
8238 }
8239
8240 if (pVertexBindingDescriptions[binding].divisor > 1) {
8241 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
8242 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
8243 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008244 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8245 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008246 "vertexAttributeInstanceRateDivisor is not enabled",
8247 binding);
8248 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008249 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06008250 if (pVertexBindingDescriptions[binding].divisor >
8251 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008252 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
8253 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8254 "].divisor is greater than maxVertexAttribDivisor",
8255 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008256 }
8257
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008258 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06008259 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008260 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
8261 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
8262 "].divisor is greater than 1 but inputRate "
8263 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
8264 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008265 }
8266 }
8267 }
8268 }
8269
8270 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008271 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06008272 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008273 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
8274 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8275 "].location is greater than maxVertexInputAttributes",
8276 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008277 }
8278
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008279 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06008280 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008281 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
8282 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8283 "].binding is greater than maxVertexInputBindings",
8284 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008285 }
8286
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07008287 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06008288 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008289 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
8290 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8291 "].offset is greater than maxVertexInputAttributeOffset",
8292 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06008293 }
8294
8295 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
8296 VkFormatProperties properties;
8297 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
8298 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
8299 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008300 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
8301 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06008302 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
8303 attribute);
8304 }
8305 }
8306
8307 return skip;
8308}
sfricke-samsung51303fb2021-05-09 19:09:13 -07008309
8310bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
8311 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
8312 const void *pValues) const {
8313 bool skip = false;
8314 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8315 // Check that offset + size don't exceed the max.
8316 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8317 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008318 skip |=
8319 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8320 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8321 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008322 }
8323 if (size > max_push_constants_size - offset) {
8324 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008325 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8326 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008327 offset, size, max_push_constants_size);
8328 }
8329
8330 // size needs to be non-zero and a multiple of 4.
8331 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008332 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8333 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008334 }
8335
8336 // offset needs to be a multiple of 4.
8337 if ((offset & 0x3) != 0) {
8338 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008339 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008340 }
8341 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008342}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008343
8344bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8345 uint32_t srcCacheCount,
8346 const VkPipelineCache *pSrcCaches) const {
8347 bool skip = false;
8348 if (pSrcCaches) {
8349 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8350 if (pSrcCaches[index0] == dstCache) {
8351 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8352 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8353 report_data->FormatHandle(dstCache).c_str());
8354 break;
8355 }
8356 }
8357 }
8358 return skip;
8359}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008360
8361bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8362 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8363 uint32_t rangeCount,
8364 const VkImageSubresourceRange *pRanges) const {
8365 bool skip = false;
8366 if (!pColor) {
8367 skip |=
8368 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8369 }
8370 return skip;
8371}
8372
8373bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8374 const VkRenderPassBeginInfo *const rp_begin) const {
8375 bool skip = false;
8376 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8377 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8378 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008379 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008380 func_name, rp_begin->clearValueCount);
8381 }
8382 return skip;
8383}
8384
8385bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8386 VkSubpassContents) const {
8387 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8388 return skip;
8389}
8390
8391bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8392 const VkRenderPassBeginInfo *pRenderPassBegin,
8393 const VkSubpassBeginInfo *) const {
8394 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8395 return skip;
8396}
8397
8398bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8399 const VkSubpassBeginInfo *) const {
8400 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8401 return skip;
8402}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008403
8404bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8405 uint32_t firstDiscardRectangle,
8406 uint32_t discardRectangleCount,
8407 const VkRect2D *pDiscardRectangles) const {
8408 bool skip = false;
8409
8410 if (pDiscardRectangles) {
8411 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8412 const int64_t x_sum =
8413 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8414 if (x_sum > std::numeric_limits<int32_t>::max()) {
8415 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8416 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8417 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8418 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8419 }
8420
8421 const int64_t y_sum =
8422 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8423 if (y_sum > std::numeric_limits<int32_t>::max()) {
8424 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8425 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8426 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8427 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8428 }
8429 }
8430 }
8431
8432 return skip;
8433}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008434
8435bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8436 uint32_t queryCount, size_t dataSize, void *pData,
8437 VkDeviceSize stride, VkQueryResultFlags flags) const {
8438 bool skip = false;
8439
8440 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8441 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8442 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8443 }
8444
8445 return skip;
8446}
ziga-lunargcf340c42021-08-19 00:13:38 +02008447
8448bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8449 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8450 bool skip = false;
8451
8452 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8453 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8454 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8455 ") is not a multiple of 4.",
8456 pConditionalRenderingBegin->offset);
8457 }
8458
8459 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008460}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008461
8462bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8463 VkSurfaceKHR surface,
8464 uint32_t *pSurfaceFormatCount,
8465 VkSurfaceFormatKHR *pSurfaceFormats) const {
8466 bool skip = false;
8467 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8468 skip |= LogError(
8469 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8470 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8471 }
8472 return skip;
8473}
8474
8475bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8476 VkSurfaceKHR surface,
8477 uint32_t *pPresentModeCount,
8478 VkPresentModeKHR *pPresentModes) const {
8479 bool skip = false;
8480 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8481 skip |= LogError(
8482 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8483 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8484 }
8485 return skip;
8486}
8487
8488bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8489 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8490 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8491 bool skip = false;
8492 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8493 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8494 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8495 "VK_GOOGLE_surfaceless_query is not enabled.");
8496 }
8497 return skip;
8498}
8499
8500bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8501 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8502 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8503 bool skip = false;
8504 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8505 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8506 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8507 "VK_GOOGLE_surfaceless_query is not enabled.");
8508 }
8509 return skip;
8510}
8511
8512#ifdef VK_USE_PLATFORM_WIN32_KHR
8513bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8514 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8515 VkPresentModeKHR *pPresentModes) const {
8516 bool skip = false;
8517 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8518 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8519 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8520 "VK_GOOGLE_surfaceless_query is not enabled.");
8521 }
8522 return skip;
8523}
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008524
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008525#endif // VK_USE_PLATFORM_WIN32_KHR
ziga-lunarg50f8e6b2021-12-18 20:24:35 +01008526
8527bool StatelessValidation::ValidateDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirementsKHR *pInfo,
8528 const char *func_name) const {
8529 bool skip = false;
8530
8531 if (pInfo && pInfo->pCreateInfo) {
8532 const auto *image_swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pInfo->pCreateInfo);
8533 if (image_swapchain_create_info) {
8534 skip |= LogError(device, "VUID-VkDeviceImageMemoryRequirementsKHR-pCreateInfo-06416",
8535 "%s(): pInfo->pCreateInfo->pNext chain contains VkImageSwapchainCreateInfoKHR.", func_name);
8536 }
8537 }
8538
8539 return skip;
8540}
8541
8542bool StatelessValidation::manual_PreCallValidateGetDeviceImageMemoryRequirementsKHR(
8543 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements) const {
8544 bool skip = false;
8545
8546 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageMemoryRequirementsKHR");
8547
8548 return skip;
8549}
8550
8551bool StatelessValidation::manual_PreCallValidateGetDeviceImageSparseMemoryRequirementsKHR(
8552 VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount,
8553 VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) const {
8554 bool skip = false;
8555
8556 skip |= ValidateDeviceImageMemoryRequirements(device, pInfo, "vkGetDeviceImageSparseMemoryRequirementsKHR");
8557
8558 return skip;
8559}