blob: 3c59a5d8c4d1992fea4b8990c7bae67ed7fa192c [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
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700242void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700243 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700244 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700245 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700246 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
247 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700249 // Parmeter validation also uses extension data
250 stateless_validation->device_extensions = this->device_extensions;
251
252 VkPhysicalDeviceProperties device_properties = {};
253 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600254 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700255 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
256
sfricke-samsung45996a42021-09-16 13:45:27 -0700257 if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700258 // Get the needed shading rate image limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700259 auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
260 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600261 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700262 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
263 }
264
sfricke-samsung45996a42021-09-16 13:45:27 -0700265 if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700266 // Get the needed mesh shader limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700267 auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>();
268 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600269 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700270 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
271 }
272
sfricke-samsung45996a42021-09-16 13:45:27 -0700273 if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) {
Jason Macnak5c954952019-07-09 15:46:12 -0700274 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700275 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>();
276 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700277 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500278 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
279 }
280
sfricke-samsung45996a42021-09-16 13:45:27 -0700281 if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500282 // Get the needed ray tracing limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700283 auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>();
284 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500285 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
286 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700287 }
288
sfricke-samsung45996a42021-09-16 13:45:27 -0700289 if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) {
sourav parmarcd5fb182020-07-17 12:58:44 -0700290 // Get the needed ray tracing acc structure limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700291 auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>();
292 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700293 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
294 phys_dev_ext_props.acc_structure_props = acc_structure_props;
295 }
296
sfricke-samsung45996a42021-09-16 13:45:27 -0700297 if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) {
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700298 // Get the needed transform feedback limits
Mark Lobodzinski6fe9e702020-12-30 15:36:39 -0700299 auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
300 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700301 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
302 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
303 }
304
sfricke-samsung45996a42021-09-16 13:45:27 -0700305 if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) {
Piers Daniellcb6d8032021-04-19 18:51:26 -0600306 // Get the needed vertex attribute divisor limits
307 auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>();
308 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props);
309 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
310 phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props;
311 }
312
sfricke-samsung45996a42021-09-16 13:45:27 -0700313 if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) {
Piers Daniella7f93b62021-11-20 12:32:04 -0700314 // Get the needed blend operation advanced properties
ziga-lunarga283d022021-08-04 18:35:23 +0200315 auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>();
316 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props);
317 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
318 phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props;
319 }
320
Piers Daniella7f93b62021-11-20 12:32:04 -0700321 if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) {
322 // Get the needed maintenance4 properties
323 auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>();
324 auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props);
325 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
326 phys_dev_ext_props.maintenance4_props = maintance4_props;
327 }
328
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800329 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700331 // Save app-enabled features in this device's validation object
332 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700333 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200334 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
335 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
336 if (features2) {
337 tmp_features2_state.features = features2->features;
338 } else if (pCreateInfo->pEnabledFeatures) {
339 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700340 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200341 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700342 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200343 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700344 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200345 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700346}
347
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700348bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500349 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600350 bool skip = false;
351
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200352 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
353 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
354 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600355 }
356
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700357 // If this device supports VK_KHR_portability_subset, it must be enabled
358 const std::string portability_extension_name("VK_KHR_portability_subset");
359 const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice);
360 const bool portability_supported = dev_extensions.count(portability_extension_name) != 0;
361 bool portability_requested = false;
362
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200363 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
364 skip |=
365 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
366 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
367 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
368 pCreateInfo->ppEnabledExtensionNames[i]);
Nathaniel Cesariob3f2d702020-11-09 09:20:49 -0700369 if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) {
370 portability_requested = true;
371 }
372 }
373
374 if (portability_supported && !portability_requested) {
375 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451",
376 "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it",
377 report_data->FormatHandle(physicalDevice).c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600378 }
379
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200380 {
aitor-lunargd5301592022-01-05 22:38:16 +0100381 bool maint1 = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700382 bool negative_viewport =
aitor-lunargd5301592022-01-05 22:38:16 +0100383 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
384 if (negative_viewport) {
385 // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to
386 // integration into api version 1.1
387 if (api_version >= VK_API_VERSION_1_1) {
388 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840",
389 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not include "
390 "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1.");
391 } else if (maint1) {
392 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
393 "vkCreateDevice(): VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include "
394 "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height.");
395 }
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200396 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600397 }
398
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600399 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200400 bool khr_bda =
401 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
402 bool ext_bda =
403 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600404 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700405 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
406 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
407 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600408 }
409 }
410
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600411 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
412 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700413 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600414 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800415 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700416 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800417 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700418 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600419 }
420 }
421
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700422 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500423 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700424 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500425 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
426 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
427 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
428 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700429 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700430 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
431 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
432 skip |= LogError(
433 device,
434 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
435 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
436 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700437 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700438 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700439 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600440 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
441 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
442 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600443 }
444
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700445 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700446 if (vulkan_11_features) {
447 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
448 while (current) {
449 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
450 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
451 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
452 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
453 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
454 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700455 skip |= LogError(
456 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700457 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
458 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
459 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
460 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
461 break;
462 }
463 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
464 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800465
466 // Check features are enabled if matching extension is passed in as well
467 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
468 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
469 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
470 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
471 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800472 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476",
sfricke-samsungebda6792021-01-16 08:57:52 -0800473 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
474 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
475 }
476 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700477 }
478
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700479 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700480 if (vulkan_12_features) {
481 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
482 while (current) {
483 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
484 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
485 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
486 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
487 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
488 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
489 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
490 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
491 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
492 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
493 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
494 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
495 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700496 skip |= LogError(
497 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700498 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
499 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
500 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
501 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
502 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
503 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
504 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
505 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
506 break;
507 }
508 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
509 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700510 // Check features are enabled if matching extension is passed in as well
511 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
512 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
513 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
514 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
515 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800516 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831",
sfricke-samsungabab4632020-05-04 06:51:46 -0700517 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
518 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
519 }
520 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
521 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
Mike Schuchardt9969d022021-12-20 15:51:55 -0800522 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832",
sfricke-samsungabab4632020-05-04 06:51:46 -0700523 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
524 "is not VK_TRUE.",
525 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
526 }
527 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
528 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
529 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800530 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833",
sfricke-samsungabab4632020-05-04 06:51:46 -0700531 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
532 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
533 }
534 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
535 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
536 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800537 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834",
sfricke-samsungabab4632020-05-04 06:51:46 -0700538 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
539 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
540 }
541 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
542 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
543 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
544 skip |=
Mike Schuchardt9969d022021-12-20 15:51:55 -0800545 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835",
sfricke-samsungabab4632020-05-04 06:51:46 -0700546 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
547 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
548 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
549 }
550 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200551 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
552 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
553 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
554 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
555 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
556 }
557 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700558 }
559
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600560 // Validate pCreateInfo->pQueueCreateInfos
561 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600562
563 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700564 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
565 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |=
568 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
569 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
570 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
571 "index value.",
572 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600573 }
574
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700575 if (queue_create_info.pQueuePriorities != nullptr) {
576 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
577 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600578 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700579 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
580 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
581 "] (=%f) is not between 0 and 1 (inclusive).",
582 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600583 }
584 }
585 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700586
587 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700588 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700589 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700590 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700591 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700592 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700593 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700594 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700595 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800596 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700597 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800598 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
599 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700600 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600601 }
602 }
603
sfricke-samsung30a57412020-05-15 21:14:54 -0700604 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700605 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700606 VkBool32 variable_pointers = VK_FALSE;
607 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700608 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700609 variable_pointers = vulkan_11_features->variablePointers;
610 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700611 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700612 variable_pointers = variable_pointers_features->variablePointers;
613 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700614 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700615 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700616 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
617 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
618 }
619
sfricke-samsungfd76c342020-05-29 23:13:43 -0700620 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700621 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700622 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700623 VkBool32 multiview_geometry_shader = VK_FALSE;
624 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700625 if (vulkan_11_features) {
626 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700627 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
628 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700629 } else if (multiview_features) {
630 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700631 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
632 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700633 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700634 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700635 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
636 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
637 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700638 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700639 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
640 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
641 }
642
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600643 return skip;
644}
645
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500646bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700647 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700648 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
649 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
650 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600651 }
652
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700653 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654}
655
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700656bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500657 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100658 bool skip = false;
659
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600660 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700661 skip |=
662 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600663
664 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
665 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
666 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
667 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
669 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
670 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600671 }
672
673 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
674 // queueFamilyIndexCount uint32_t values
675 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700676 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
677 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
678 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
679 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600680 }
681 }
682
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700683 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
684 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
685 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
686 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
687 }
688
689 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
690 skip |=
691 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
692 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
693 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
694 }
695
696 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
697 skip |=
698 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
699 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
700 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
701 }
702
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
704 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
705 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
706 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700707 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
708 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
709 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600710 }
Piers Daniella7f93b62021-11-20 12:32:04 -0700711
712 const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext);
713 if (maintenance4_features && maintenance4_features->maintenance4) {
714 if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) {
715 skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409",
716 "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size "
717 "VkPhysicalDeviceMaintenance4Properties.maxBufferSize");
718 }
719 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600720 }
721
722 return skip;
723}
724
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700725bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500726 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600727 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600728
729 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800730 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700731 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600732 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
733 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
734 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
735 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700736 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
737 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
738 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600739 }
740
741 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
742 // queueFamilyIndexCount uint32_t values
743 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
745 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
746 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
747 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600748 }
749 }
750
Dave Houlton413a6782018-05-22 13:01:54 -0600751 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700752 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600753 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700754 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600755 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700756 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600757
Dave Houlton413a6782018-05-22 13:01:54 -0600758 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700759 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600760 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700761 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600762
Dave Houlton130c0212018-01-29 13:39:56 -0700763 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700764 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
765 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(
767 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600768 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
769 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700770 }
771
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600772 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100773 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
774 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700775 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
776 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
777 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600778 }
779
780 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700781 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100782 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700783 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
784 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
785 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
786 ") are not equal.",
787 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100788 }
789
790 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
792 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
793 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
794 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100795 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600796 }
797
798 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700799 skip |= LogError(
800 device, "VUID-VkImageCreateInfo-imageType-00957",
801 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600802 }
803 }
804
Dave Houlton130c0212018-01-29 13:39:56 -0700805 // 3D image may have only 1 layer
806 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700807 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
808 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700809 }
810
Dave Houlton130c0212018-01-29 13:39:56 -0700811 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
812 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
813 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
814 // At least one of the legal attachment bits must be set
815 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
817 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700818 }
819 // No flags other than the legal attachment bits may be set
820 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
821 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
823 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700824 }
825 }
826
Jeff Bolzef40fec2018-09-01 22:04:34 -0500827 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700828 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500829 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700830 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700831 ? static_cast<uint32_t>(ceil(log2(max_dim)))
832 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
833 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600834 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700835 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
836 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
837 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600838 }
839
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700840 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700841 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
842 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
843 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600844 }
845
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700846 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
848 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
849 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100850 }
851
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700852 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700853 skip |= LogError(
854 device, "VUID-VkImageCreateInfo-flags-01924",
855 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
856 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
857 }
858
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600859 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
860 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700861 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
862 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700863 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
864 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
865 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600866 }
867
868 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700869 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600870 // Linear tiling is unsupported
871 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700872 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700873 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
874 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600875 }
876
877 // Sparse 1D image isn't valid
878 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700879 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
880 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600881 }
882
883 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700884 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
886 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
887 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600888 }
889
890 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700891 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700892 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
893 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
894 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600895 }
896
897 // Multi-sample 2D image when device doesn't support it
898 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700899 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600900 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700901 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
902 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
903 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700904 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600905 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
907 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
908 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700909 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600910 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700911 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
912 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
913 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700914 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600915 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700916 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
917 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
918 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600919 }
920 }
921 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500922
Jeff Bolz9af91c52018-09-01 21:53:57 -0500923 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
924 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700925 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
926 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
927 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500928 }
929 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700930 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
931 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
932 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500933 }
934 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700935 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
936 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
937 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500938 }
939 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500940
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700941 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600942 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700943 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
944 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
945 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500946 }
947
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700948 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
950 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800951 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
952 "depth/stencil format.",
953 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500954 }
955
Dave Houlton142c4cb2018-10-17 15:04:41 -0600956 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700957 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
958 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
959 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
960 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500961 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600962 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700963 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
964 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
965 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
966 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500967 }
968 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500969
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700970 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800971 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700972 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
973 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800974 "format (%s) must be a depth or depth/stencil format.",
975 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700976 }
977
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700978 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500979 if (image_stencil_struct != nullptr) {
980 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
981 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
982 // No flags other than the legal attachment bits may be set
983 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
984 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700985 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
986 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
987 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
988 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500989 }
990 }
991
sfricke-samsung61a57c02021-01-10 21:35:12 -0800992 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500993 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
994 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -0700995 skip |=
996 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
997 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
998 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
999 ") exceeds device "
1000 "maxFramebufferWidth (%" PRIu32 ")",
1001 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001002 }
1003
1004 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001005 skip |=
1006 LogError(device, "VUID-VkImageCreateInfo-format-02537",
1007 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1008 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
1009 ") exceeds device "
1010 "maxFramebufferHeight (%" PRIu32 ")",
1011 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001012 }
1013 }
1014
1015 if (!physical_device_features.shaderStorageImageMultisample &&
1016 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1017 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1018 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001019 LogError(device, "VUID-VkImageCreateInfo-format-02538",
1020 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1021 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
1022 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001023 }
1024
1025 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1026 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001027 skip |= LogError(
1028 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001029 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1030 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1031 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1032 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1033 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001034 skip |= LogError(
1035 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001036 "vkCreateImage(): Depth-stencil image in which usage does not include "
1037 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1038 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1039 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1040 }
1041
1042 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1043 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001044 skip |= LogError(
1045 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001046 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1047 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1048 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1049 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1050 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001051 skip |= LogError(
1052 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001053 "vkCreateImage(): Depth-stencil image in which usage does not include "
1054 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1055 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1056 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1057 }
1058 }
1059 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001060
1061 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1062 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1063 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1064 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1065 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1066 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001067
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001068 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001069 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001070 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1071 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001072 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1073 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1074 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1075 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1076 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1077 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1078 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001079 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001080 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1081 } else if (drm_format_mod_list != nullptr) {
1082 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1083 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1084 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001085 }
1086 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1087 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1088 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1089 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1090 "in the pNext chain");
1091 }
1092 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001093
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001094 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001095 bool image_create_maybe_linear = false;
1096 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1097 image_create_maybe_linear = true;
1098 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1099 image_create_maybe_linear = false;
1100 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1101 image_create_maybe_linear =
1102 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001103 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001104 }
1105
1106 // If multi-sample, validate type, usage, tiling and mip levels.
1107 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001108 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001109 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1110 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1111 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1112 }
1113
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001114 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001115 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1116 image_create_maybe_linear)) {
1117 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1118 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1119 }
1120
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001121 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1122 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1123 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1124 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1125 "imageType must be VK_IMAGE_TYPE_2D.");
1126 }
1127 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1128 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1129 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1130 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1131 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001132 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001133 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001134 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1135 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1136 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1137 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1138 }
1139 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1140 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1141 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1142 "imageType must be VK_IMAGE_TYPE_2D.");
1143 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001144 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001145 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1146 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1147 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1148 }
1149 if (pCreateInfo->mipLevels != 1) {
1150 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001151 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1152 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001153 pCreateInfo->mipLevels);
1154 }
1155 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001156
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001157 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001158 if (swapchain_create_info != nullptr) {
1159 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1160 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1161 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1162 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1163 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1164 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1165
1166 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1167 // also implicitly forces the check above that extent.depth is 1
1168 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1169 string_VkImageType(pCreateInfo->imageType));
1170 }
1171 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001172 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001173 pCreateInfo->mipLevels);
1174 }
1175 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1176 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1177 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1178 }
1179 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1180 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1181 base_message, string_VkImageTiling(pCreateInfo->tiling));
1182 }
1183 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1184 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1185 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1186 }
1187 const VkImageCreateFlags valid_flags =
1188 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001189 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001190 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001191 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001192 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001193 }
1194 }
1195 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001196
1197 // If Chroma subsampled format ( _420_ or _422_ )
1198 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1199 skip |=
1200 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1201 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1202 ") must be a multiple of 2.",
1203 string_VkFormat(image_format), pCreateInfo->extent.width);
1204 }
1205 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1206 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1207 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1208 ") must be a multiple of 2.",
1209 string_VkFormat(image_format), pCreateInfo->extent.height);
1210 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001211
1212 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1213 if (format_list_info) {
1214 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1215 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1216 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1217 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001218 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001219 viewFormatCount);
1220 }
1221 // Check if viewFormatCount is not zero that it is all compatible
1222 for (uint32_t i = 0; i < viewFormatCount; i++) {
1223 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1224 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001225 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1226 "] (%s) and "
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001227 "VkImageCreateInfo::format (%s) are not compatible.",
Esther O'Keefed37c24b2021-09-27 12:45:40 +10001228 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001229 }
1230 }
1231 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001232 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001233
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001234 return skip;
1235}
1236
Jeff Bolz99e3f632020-03-24 22:59:22 -05001237bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1238 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1239 bool skip = false;
1240
1241 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001242 // Validate feature set if using CUBE_ARRAY
1243 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1244 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1245 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1246 "enabling the imageCubeArray feature.");
1247 }
1248
Jeff Bolz99e3f632020-03-24 22:59:22 -05001249 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1250 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1251 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001252 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1253 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001254 pCreateInfo->subresourceRange.layerCount);
1255 }
1256 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001257 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1258 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1259 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1260 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001261 }
1262 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001263
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001264 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001265 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001266 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1267 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1268 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1269 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1270 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1271 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1272 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001273 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1274 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001275 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1276 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1277 "not an ASTC format.",
1278 string_VkFormat(pCreateInfo->format));
1279 }
1280 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001281
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001282 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001283 if (ycbcr_conversion != nullptr) {
1284 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1285 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1286 skip |= LogError(
1287 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1288 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1289 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1290 "r swizzle = %s\n"
1291 "g swizzle = %s\n"
1292 "b swizzle = %s\n"
1293 "a swizzle = %s\n",
1294 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1295 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1296 }
1297 }
1298 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001299 }
1300 return skip;
1301}
1302
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001303bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001304 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001305 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001306
1307 // Note: for numerical correctness
1308 // - float comparisons should expect NaN (comparison always false).
1309 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1310
1311 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001312 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001313 if (v1_f <= 0.0f) return true;
1314
1315 float intpart;
1316 const float fract = modff(v1_f, &intpart);
1317
1318 assert(std::numeric_limits<float>::radix == 2);
1319 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1320 if (intpart >= u32_max_plus1) return false;
1321
1322 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001323 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001324 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001325 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001326 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001327 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001328 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001329 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001330 };
1331
1332 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1333 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1334 return (v1_f <= v2_f);
1335 };
1336
1337 // width
1338 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001339 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001340
1341 if (!(viewport.width > 0.0f)) {
1342 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001343 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1344 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001345 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1346 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001347 skip |= LogError(object, "VUID-VkViewport-width-01771",
1348 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1349 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001350 }
1351
1352 // height
1353 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001354 const bool negative_height_enabled =
1355 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001356 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001357
1358 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1359 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001360 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1361 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001362 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1363 height_healthy = false;
1364
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001365 skip |= LogError(object, "VUID-VkViewport-height-01773",
1366 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1367 ").",
1368 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001369 }
1370
1371 // x
1372 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001373 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001374 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001375 skip |= LogError(object, "VUID-VkViewport-x-01774",
1376 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1377 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001378 }
1379
1380 // x + width
1381 if (x_healthy && width_healthy) {
1382 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001383 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001384 skip |= LogError(
1385 object, "VUID-VkViewport-x-01232",
1386 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1387 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1388 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001389 }
1390 }
1391
1392 // y
1393 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001394 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001395 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001396 skip |= LogError(object, "VUID-VkViewport-y-01775",
1397 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1398 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001399 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001400 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001401 skip |= LogError(object, "VUID-VkViewport-y-01776",
1402 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1403 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001404 }
1405
1406 // y + height
1407 if (y_healthy && height_healthy) {
1408 const float boundary = viewport.y + viewport.height;
1409
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001410 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001411 skip |= LogError(object, "VUID-VkViewport-y-01233",
1412 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1413 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1414 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001415 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001416 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001417 LogError(object, "VUID-VkViewport-y-01777",
1418 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1419 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1420 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001421 }
1422 }
1423
sfricke-samsungfd06d422021-01-22 02:17:21 -08001424 // 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 -07001425 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001426 // minDepth
1427 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001428 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001429 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001430 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1431 "[0.0, 1.0] range.",
1432 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001433 }
1434
1435 // maxDepth
1436 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001437 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001438 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001439 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1440 "[0.0, 1.0] range.",
1441 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001442 }
1443 }
1444
1445 return skip;
1446}
1447
Dave Houlton142c4cb2018-10-17 15:04:41 -06001448struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001449 VkShadingRatePaletteEntryNV shadingRate;
1450 uint32_t width;
1451 uint32_t height;
1452};
1453
1454// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001455static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001456 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1457 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1458 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1459 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1460 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1461 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001462};
1463
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001464bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001465 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001466
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001467 SampleOrderInfo *sample_order_info;
1468 uint32_t info_idx = 0;
1469 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1470 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1471 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001472 break;
1473 }
1474 }
1475
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001476 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001477 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1478 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1479 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001480 return skip;
1481 }
1482
Dave Houlton142c4cb2018-10-17 15:04:41 -06001483 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001484 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001485 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1486 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1487 ") must "
1488 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1489 "is set in framebufferNoAttachmentsSampleCounts.",
1490 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001491 }
1492
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001493 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001494 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1495 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1496 ") must "
1497 "be equal to the product of sampleCount (=%" PRIu32
1498 "), the fragment width for shadingRate "
1499 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001500 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001501 }
1502
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001503 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001504 skip |= LogError(
1505 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001506 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1507 ") must "
1508 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001509 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001510 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001511
1512 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001513 // the first width*height*sampleCount bits to all be set. Note: There is no
1514 // guarantee that 64 bits is enough, but practically it's unlikely for an
1515 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001516 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001517 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001518 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001519 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1520 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001521 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1522 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001523 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001524 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001525 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1526 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001527 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001528 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001529 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1530 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001531 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001532 uint32_t idx =
1533 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1534 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001535 }
1536
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001537 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1538 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001539 skip |= LogError(
1540 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001541 "The array pSampleLocations must contain exactly one entry for "
1542 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001543 }
1544
1545 return skip;
1546}
1547
sfricke-samsung51303fb2021-05-09 19:09:13 -07001548bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1549 const VkAllocationCallbacks *pAllocator,
1550 VkPipelineLayout *pPipelineLayout) const {
1551 bool skip = false;
1552 // Validate layout count against device physical limit
1553 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1554 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001555 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1556 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001557 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1558 }
1559
1560 // Validate Push Constant ranges
1561 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1562 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1563 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1564 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1565 // Check that offset + size don't exceed the max.
1566 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1567 if (offset >= max_push_constants_size) {
1568 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001569 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1570 ") that exceeds this "
1571 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001572 i, offset, max_push_constants_size);
1573 }
1574 if (size > max_push_constants_size - offset) {
1575 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001576 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1577 ") and size (%" PRIu32
1578 ") "
1579 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001580 i, offset, size, max_push_constants_size);
1581 }
1582
1583 // size needs to be non-zero and a multiple of 4.
1584 if (size == 0) {
1585 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001586 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1587 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001588 i, size);
1589 }
1590 if (size & 0x3) {
1591 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001592 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1593 ") is not a multiple of 4.",
1594 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001595 }
1596
1597 // offset needs to be a multiple of 4.
1598 if ((offset & 0x3) != 0) {
1599 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001600 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1601 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001602 i, offset);
1603 }
1604 }
1605
1606 // 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.
1607 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1608 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1609 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001610 skip |=
1611 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1612 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001613 }
1614 }
1615 }
1616 return skip;
1617}
1618
ziga-lunargc6341372021-07-28 12:57:42 +02001619bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1620 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1621 bool skip = false;
1622
1623 const auto *required_subgroup_size_features =
1624 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1625
1626 if (required_subgroup_size_features) {
1627 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1628 skip |= LogError(
1629 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1630 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1631 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1632 func_name, msg, pCreateInfo->flags);
1633 }
1634 }
1635
1636 return skip;
1637}
1638
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001639bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1640 uint32_t createInfoCount,
1641 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1642 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001643 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001644 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001645
1646 if (pCreateInfos != nullptr) {
1647 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001648 bool has_dynamic_viewport = false;
1649 bool has_dynamic_scissor = false;
1650 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001651 bool has_dynamic_depth_bias = false;
1652 bool has_dynamic_blend_constant = false;
1653 bool has_dynamic_depth_bounds = false;
1654 bool has_dynamic_stencil_compare = false;
1655 bool has_dynamic_stencil_write = false;
1656 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001657 bool has_dynamic_viewport_w_scaling_nv = false;
1658 bool has_dynamic_discard_rectangle_ext = false;
1659 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001660 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001661 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001662 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001663 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001664 bool has_dynamic_cull_mode = false;
1665 bool has_dynamic_front_face = false;
1666 bool has_dynamic_primitive_topology = false;
1667 bool has_dynamic_viewport_with_count = false;
1668 bool has_dynamic_scissor_with_count = false;
1669 bool has_dynamic_vertex_input_binding_stride = false;
1670 bool has_dynamic_depth_test_enable = false;
1671 bool has_dynamic_depth_write_enable = false;
1672 bool has_dynamic_depth_compare_op = false;
1673 bool has_dynamic_depth_bounds_test_enable = false;
1674 bool has_dynamic_stencil_test_enable = false;
1675 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001676 bool has_patch_control_points = false;
1677 bool has_rasterizer_discard_enable = false;
1678 bool has_depth_bias_enable = false;
1679 bool has_logic_op = false;
1680 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001681 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001682 if (pCreateInfos[i].pDynamicState != nullptr) {
1683 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1684 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1685 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001686 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1687 if (has_dynamic_viewport == true) {
1688 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1689 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001690 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001691 i);
1692 }
1693 has_dynamic_viewport = true;
1694 }
1695 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1696 if (has_dynamic_scissor == true) {
1697 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1698 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001699 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001700 i);
1701 }
1702 has_dynamic_scissor = true;
1703 }
1704 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1705 if (has_dynamic_line_width == true) {
1706 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1707 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001708 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001709 i);
1710 }
1711 has_dynamic_line_width = true;
1712 }
1713 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1714 if (has_dynamic_depth_bias == true) {
1715 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1716 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001717 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001718 i);
1719 }
1720 has_dynamic_depth_bias = true;
1721 }
1722 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1723 if (has_dynamic_blend_constant == true) {
1724 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1725 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001726 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001727 i);
1728 }
1729 has_dynamic_blend_constant = true;
1730 }
1731 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1732 if (has_dynamic_depth_bounds == true) {
1733 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1734 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001735 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001736 i);
1737 }
1738 has_dynamic_depth_bounds = true;
1739 }
1740 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1741 if (has_dynamic_stencil_compare == true) {
1742 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1743 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001744 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001745 i);
1746 }
1747 has_dynamic_stencil_compare = true;
1748 }
1749 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1750 if (has_dynamic_stencil_write == true) {
1751 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1752 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001753 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001754 i);
1755 }
1756 has_dynamic_stencil_write = true;
1757 }
1758 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1759 if (has_dynamic_stencil_reference == true) {
1760 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1761 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001762 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001763 i);
1764 }
1765 has_dynamic_stencil_reference = true;
1766 }
1767 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1768 if (has_dynamic_viewport_w_scaling_nv == true) {
1769 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1770 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001771 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001772 i);
1773 }
1774 has_dynamic_viewport_w_scaling_nv = true;
1775 }
1776 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1777 if (has_dynamic_discard_rectangle_ext == true) {
1778 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1779 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001780 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001781 i);
1782 }
1783 has_dynamic_discard_rectangle_ext = true;
1784 }
1785 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1786 if (has_dynamic_sample_locations_ext == true) {
1787 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1788 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001789 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001790 i);
1791 }
1792 has_dynamic_sample_locations_ext = true;
1793 }
1794 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1795 if (has_dynamic_exclusive_scissor_nv == true) {
1796 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1797 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001798 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001799 i);
1800 }
1801 has_dynamic_exclusive_scissor_nv = true;
1802 }
1803 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1804 if (has_dynamic_shading_rate_palette_nv == true) {
1805 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1806 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001807 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001808 i);
1809 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001810 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001811 }
1812 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1813 if (has_dynamic_viewport_course_sample_order_nv == true) {
1814 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1815 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001816 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001817 i);
1818 }
1819 has_dynamic_viewport_course_sample_order_nv = true;
1820 }
1821 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1822 if (has_dynamic_line_stipple == true) {
1823 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1824 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001825 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001826 i);
1827 }
1828 has_dynamic_line_stipple = true;
1829 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001830 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1831 if (has_dynamic_cull_mode) {
1832 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1833 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001834 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001835 i);
1836 }
1837 has_dynamic_cull_mode = true;
1838 }
1839 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1840 if (has_dynamic_front_face) {
1841 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1842 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001843 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001844 i);
1845 }
1846 has_dynamic_front_face = true;
1847 }
1848 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1849 if (has_dynamic_primitive_topology) {
1850 skip |= LogError(
1851 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1852 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001853 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001854 i);
1855 }
1856 has_dynamic_primitive_topology = true;
1857 }
1858 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1859 if (has_dynamic_viewport_with_count) {
1860 skip |= LogError(
1861 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1862 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001863 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001864 i);
1865 }
1866 has_dynamic_viewport_with_count = true;
1867 }
1868 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1869 if (has_dynamic_scissor_with_count) {
1870 skip |= LogError(
1871 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1872 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001873 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001874 i);
1875 }
1876 has_dynamic_scissor_with_count = true;
1877 }
1878 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1879 if (has_dynamic_vertex_input_binding_stride) {
1880 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1881 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1882 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001883 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001884 i);
1885 }
1886 has_dynamic_vertex_input_binding_stride = true;
1887 }
1888 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1889 if (has_dynamic_depth_test_enable) {
1890 skip |= LogError(
1891 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1892 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001893 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001894 i);
1895 }
1896 has_dynamic_depth_test_enable = true;
1897 }
1898 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1899 if (has_dynamic_depth_write_enable) {
1900 skip |= LogError(
1901 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1902 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001903 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001904 i);
1905 }
1906 has_dynamic_depth_write_enable = true;
1907 }
1908 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1909 if (has_dynamic_depth_compare_op) {
1910 skip |=
1911 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1912 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001913 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001914 i);
1915 }
1916 has_dynamic_depth_compare_op = true;
1917 }
1918 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1919 if (has_dynamic_depth_bounds_test_enable) {
1920 skip |= LogError(
1921 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1922 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001923 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001924 i);
1925 }
1926 has_dynamic_depth_bounds_test_enable = true;
1927 }
1928 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1929 if (has_dynamic_stencil_test_enable) {
1930 skip |= LogError(
1931 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1932 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001933 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001934 i);
1935 }
1936 has_dynamic_stencil_test_enable = true;
1937 }
1938 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1939 if (has_dynamic_stencil_op) {
1940 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1941 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001942 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001943 i);
1944 }
1945 has_dynamic_stencil_op = true;
1946 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001947 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1948 // Not allowed for graphics pipelines
1949 skip |= LogError(
1950 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1951 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001952 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
1953 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001954 i, state_index);
1955 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001956 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1957 if (has_patch_control_points) {
1958 skip |= LogError(
1959 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1960 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001961 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001962 i);
1963 }
1964 has_patch_control_points = true;
1965 }
1966 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1967 if (has_rasterizer_discard_enable) {
1968 skip |= LogError(
1969 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1970 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001971 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001972 i);
1973 }
1974 has_rasterizer_discard_enable = true;
1975 }
1976 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1977 if (has_depth_bias_enable) {
1978 skip |= LogError(
1979 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1980 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001981 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001982 i);
1983 }
1984 has_depth_bias_enable = true;
1985 }
1986 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1987 if (has_logic_op) {
1988 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1989 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001990 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001991 i);
1992 }
1993 has_logic_op = true;
1994 }
1995 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1996 if (has_primitive_restart_enable) {
1997 skip |= LogError(
1998 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1999 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002000 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07002001 i);
2002 }
2003 has_primitive_restart_enable = true;
2004 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06002005 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
2006 if (has_dynamic_vertex_input) {
2007 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002008 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2009 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2010 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002011 }
2012 has_dynamic_vertex_input = true;
2013 }
Petr Kraus299ba622017-11-24 03:09:03 +01002014 }
2015 }
2016
sfricke-samsung3b944422021-01-23 02:15:19 -08002017 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2018 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2019 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002020 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2021 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002022 i);
2023 }
2024
2025 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2026 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2027 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002028 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002029 i);
2030 }
2031
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002032 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002033 if ((feedback_struct != nullptr) &&
2034 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002035 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
2036 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2037 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2038 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
2039 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002040 }
2041
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002042 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002043
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002044 // Collect active stages and other information
2045 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002046 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002047 bool has_eval = false;
2048 bool has_control = false;
2049 if (pCreateInfos[i].pStages != nullptr) {
2050 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2051 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2052
2053 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2054 has_control = true;
2055 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2056 has_eval = true;
2057 }
2058
2059 skip |= validate_string(
2060 "vkCreateGraphicsPipelines",
2061 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2062 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002063
2064 std::stringstream msg;
2065 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2066 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2067 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002068 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002069 }
2070
2071 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2072 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2073 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2074 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2075 pCreateInfos[i].pTessellationState,
2076 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2077 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2078
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002079 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002080 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2081
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002082 skip |= validate_struct_pnext(
2083 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2084 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2085 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2086 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2087 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2088 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002089
2090 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2091 pCreateInfos[i].pTessellationState->flags,
2092 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2093 }
2094
2095 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2096 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2097 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2098 pCreateInfos[i].pInputAssemblyState,
2099 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2100 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2101
2102 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2103 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002104 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002105
2106 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2107 pCreateInfos[i].pInputAssemblyState->flags,
2108 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2109
2110 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2111 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2112 pCreateInfos[i].pInputAssemblyState->topology,
2113 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2114
2115 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2116 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2117 }
2118
2119 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002120 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002121
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002122 if (pCreateInfos[i].pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002123 skip |=
2124 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2125 "vkCreateGraphicsPipelines: pararameter "
2126 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2127 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002128 }
2129
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002130 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002131 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2132 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2133 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2134 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002135 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2136 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002137 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002138 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2139 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002140 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002141 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2142 skip |=
2143 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2144 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2145 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2146 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2147 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2148
2149 skip |= validate_array(
2150 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2151 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2152 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2153 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2154
2155 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002156 for (uint32_t vertex_binding_description_index = 0;
2157 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2158 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002159 skip |= validate_ranged_enum(
2160 "vkCreateGraphicsPipelines",
2161 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2162 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002163 pCreateInfos[i]
2164 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2165 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002166 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2167 }
2168 }
2169
2170 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002171 for (uint32_t vertex_attribute_description_index = 0;
2172 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2173 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002174 const VkFormat format =
2175 pCreateInfos[i]
2176 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2177 .format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002178 skip |= validate_ranged_enum(
2179 "vkCreateGraphicsPipelines",
2180 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2181 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002182 pCreateInfos[i]
2183 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2184 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002185 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002186 if (FormatIsDepthOrStencil(format)) {
2187 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2188 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2189 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2190 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002191 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2192 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002193 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2194 "alignment, replace with a color format.",
2195 i, vertex_attribute_description_index, string_VkFormat(format));
2196 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002197 }
2198 }
2199
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002200 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002201 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2202 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002203 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2204 ") is "
2205 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002206 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002207 }
2208
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002209 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002210 skip |=
2211 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2212 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002213 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2214 ") is "
2215 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002216 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002217 }
2218
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002219 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002220 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2221 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002222 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2223 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002224 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2225 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002226 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2227 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002228 "(%" PRIu32 ") is not distinct.",
2229 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002230 }
2231 vertex_bindings.insert(vertex_bind_desc.binding);
2232
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002233 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002234 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2235 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002236 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2237 "].binding (%" PRIu32
2238 ") is "
2239 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002240 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002241 }
2242
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002243 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002244 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2245 "vkCreateGraphicsPipelines: parameter "
2246 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2247 "].stride (%" PRIu32
2248 ") is greater "
2249 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2250 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002251 }
2252 }
2253
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002254 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002255 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2256 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002257 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2258 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002259 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2260 "vkCreateGraphicsPipelines: parameter "
2261 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2262 "].location (%" PRIu32 ") is not distinct.",
2263 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002264 }
2265 attribute_locations.insert(vertex_attrib_desc.location);
2266
2267 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2268 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002269 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2270 "vkCreateGraphicsPipelines: parameter "
2271 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2272 "].binding (%" PRIu32
2273 ") does not exist "
2274 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2275 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002276 }
2277
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002278 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002279 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2280 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002281 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2282 "].location (%" PRIu32
2283 ") is "
2284 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002285 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002286 }
2287
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002288 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002289 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2290 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002291 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2292 "].binding (%" PRIu32
2293 ") is "
2294 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002295 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002296 }
2297
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002298 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002299 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2300 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002301 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2302 "].offset (%" PRIu32
2303 ") is "
2304 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002305 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002306 }
2307 }
2308 }
2309
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002310 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2311 if (has_control && has_eval) {
2312 if (pCreateInfos[i].pTessellationState == nullptr) {
2313 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002314 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2315 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002316 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002317 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002318 i, i);
2319 } else {
2320 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2321 skip |= validate_struct_pnext(
2322 "vkCreateGraphicsPipelines",
2323 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2324 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2325 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2326 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002327
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002328 skip |= validate_reserved_flags(
2329 "vkCreateGraphicsPipelines",
2330 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2331 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002333 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2334 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2335 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2336 "vkCreateGraphicsPipelines: invalid parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002337 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2338 ". patchControlPoints "
2339 "should be >0 and <=%" PRIu32 ".",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002340 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2341 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 }
2343 }
2344 }
2345
2346 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2347 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2348 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2349 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002350 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2351 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2352 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2353 "].pViewportState (=NULL) is not a valid pointer.",
2354 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002355 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002356 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2357
2358 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002359 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2360 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2361 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2362 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 }
2364
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002365 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002366 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002367 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2368 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002369 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2370 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002371 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002372 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002373 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002374 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002375 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002376 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002377 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002378 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002379 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002380 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002381 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002382 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383
2384 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002385 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002386 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002387 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002389 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002390 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002391 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002392 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002393 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002394 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2395 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002396 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002397 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2398 const auto depth_clip_control_struct =
2399 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002400
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002401 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002402 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002403 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2404 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2405 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2406 ") is not 1.",
2407 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002408 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002409
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002410 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002411 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2412 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2413 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2414 ") is not 1.",
2415 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002416 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002417
Dave Houlton142c4cb2018-10-17 15:04:41 -06002418 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2419 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002420 skip |= LogError(
2421 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2422 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2423 "disabled, but pCreateInfos[%" PRIu32
2424 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2425 ") is not 1.",
2426 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002427 }
2428
Jeff Bolz9af91c52018-09-01 21:53:57 -05002429 if (shading_rate_image_struct &&
2430 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002431 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2432 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2433 "disabled, but pCreateInfos[%" PRIu32
2434 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2435 ") is neither 0 nor 1.",
2436 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002437 }
2438
Petr Krausa6103552017-11-16 21:21:58 +01002439 } else { // multiViewport enabled
2440 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002441 if (!has_dynamic_viewport_with_count) {
2442 skip |= LogError(
2443 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2444 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2445 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002446 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002447 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2448 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2449 "].pViewportState->viewportCount (=%" PRIu32
2450 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2451 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002452 } else if (has_dynamic_viewport_with_count) {
2453 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2454 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2455 "].pViewportState->viewportCount (=%" PRIu32
2456 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2457 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002458 }
Petr Krausa6103552017-11-16 21:21:58 +01002459
2460 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002461 if (!has_dynamic_scissor_with_count) {
2462 skip |= LogError(
2463 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2464 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2465 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002466 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002467 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2468 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2469 "].pViewportState->scissorCount (=%" PRIu32
2470 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2471 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002472 } else if (has_dynamic_scissor_with_count) {
2473 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2474 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2475 "].pViewportState->scissorCount (=%" PRIu32
2476 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2477 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002478 }
2479 }
2480
ziga-lunarg845883b2021-07-14 15:05:00 +02002481 if (!has_dynamic_scissor && viewport_state.pScissors) {
2482 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2483 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002484
2485 if (scissor.offset.x < 0) {
2486 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2487 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2488 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2489 scissor.offset.x, i, scissor_i);
2490 }
2491
2492 if (scissor.offset.y < 0) {
2493 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2494 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2495 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2496 scissor.offset.y, i, scissor_i);
2497 }
2498
ziga-lunarg845883b2021-07-14 15:05:00 +02002499 const int64_t x_sum =
2500 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2501 if (x_sum > std::numeric_limits<int32_t>::max()) {
2502 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2503 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2504 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2505 "] will overflow int32_t.",
2506 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2507 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002508
ziga-lunarg845883b2021-07-14 15:05:00 +02002509 const int64_t y_sum =
2510 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2511 if (y_sum > std::numeric_limits<int32_t>::max()) {
2512 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2513 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2514 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2515 "] will overflow int32_t.",
2516 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2517 }
2518 }
2519 }
2520
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002521 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |=
2523 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2524 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2525 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2526 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002527 }
2528
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002529 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2531 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2532 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2533 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2534 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002535 }
2536
Piers Daniell39842ee2020-07-10 16:42:33 -06002537 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2538 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2540 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2541 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2542 "].pViewportState->viewportCount (=%" PRIu32 ").",
2543 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002544 }
2545
Dave Houlton142c4cb2018-10-17 15:04:41 -06002546 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002547 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002548 skip |=
2549 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2550 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2551 ") must be zero or identical to pCreateInfos[%" PRIu32
2552 "].pViewportState->viewportCount (=%" PRIu32 ").",
2553 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002554 }
2555
Dave Houlton142c4cb2018-10-17 15:04:41 -06002556 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002557 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002558 skip |= LogError(
2559 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002560 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2561 "] "
2562 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2563 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2564 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002565 }
2566
Petr Krausa6103552017-11-16 21:21:58 +01002567 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002568 skip |= LogError(
2569 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002570 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2571 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002572 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2573 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002574 }
2575
2576 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002577 skip |= LogError(
2578 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002579 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2580 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002581 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2582 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002583 }
2584
Jeff Bolz3e71f782018-08-29 23:15:45 -05002585 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002586 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2587 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2588 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002589 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002590 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2591 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2592 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2593 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002594 }
2595
Jeff Bolz9af91c52018-09-01 21:53:57 -05002596 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002597 shading_rate_image_struct->viewportCount > 0 &&
2598 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002599 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002600 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002601 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002602 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2603 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002604 i, i);
2605 }
2606
Chris Mayer328d8212018-12-11 14:16:18 +01002607 if (vp_swizzle_struct) {
2608 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002609 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2610 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2611 " does "
2612 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2613 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002614 }
2615 }
2616
Petr Krausb3fcdb42018-01-09 22:09:09 +01002617 // validate the VkViewports
2618 if (!has_dynamic_viewport && viewport_state.pViewports) {
2619 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2620 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002621 const char *fn_name = "vkCreateGraphicsPipelines";
2622 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2623 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2624 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002625 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002626 }
2627 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002628
sfricke-samsung45996a42021-09-16 13:45:27 -07002629 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002630 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2631 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2632 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2633 "VK_NV_clip_space_w_scaling extension is not enabled.",
2634 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002635 }
2636
sfricke-samsung45996a42021-09-16 13:45:27 -07002637 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002638 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2639 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2640 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2641 "VK_EXT_discard_rectangles extension is not enabled.",
2642 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002643 }
2644
sfricke-samsung45996a42021-09-16 13:45:27 -07002645 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002646 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2647 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2648 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2649 "VK_EXT_sample_locations extension is not enabled.",
2650 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002651 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002652
sfricke-samsung45996a42021-09-16 13:45:27 -07002653 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002654 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2655 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2656 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2657 "VK_NV_scissor_exclusive extension is not enabled.",
2658 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002659 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002660
2661 if (coarse_sample_order_struct &&
2662 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2663 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002664 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2665 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2666 "] "
2667 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2668 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2669 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002670 }
2671
2672 if (coarse_sample_order_struct) {
2673 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002674 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002675 }
2676 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002677
2678 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2679 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002680 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2681 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2682 "] "
2683 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2684 ") "
2685 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2686 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002687 }
2688 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002689 skip |= LogError(
2690 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002691 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2692 "] "
2693 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2694 i);
2695 }
2696 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002697
2698 if (depth_clip_control_struct) {
2699 const auto *depth_clip_control_features =
2700 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2701 const bool enabled_depth_clip_control =
2702 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2703 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2704 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2705 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2706 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2707 "depthClipControl feature is not enabled. ",
2708 i);
2709 }
2710 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002711 }
2712
2713 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002714 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002715 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2716 "].pRasterizationState->rasterizerDiscardEnable "
2717 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002718 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002719 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002720 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002721 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002722 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2723 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002724 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002725 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002726 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002727 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002728 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002729 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002730 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002731 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2732 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733
2734 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002735 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002736 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002737 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002738
2739 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002740 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002741 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2742 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2743
2744 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002745 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002746 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2747 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002748 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002749 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002750
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002751 skip |= validate_flags(
2752 "vkCreateGraphicsPipelines",
2753 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2754 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002755 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002756
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002758 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2760 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2761
2762 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002763 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002764 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2765 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2766
2767 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002768 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002769 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2770 "].pMultisampleState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002771 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2772 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002773 }
John Zulauf7acac592017-11-06 11:15:53 -07002774 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002775 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002776 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2777 "vkCreateGraphicsPipelines(): parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002778 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002779 i);
John Zulauf7acac592017-11-06 11:15:53 -07002780 }
2781 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2782 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2783 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002784 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002785
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002786 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2787 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2788 "].pMultisampleState->minSampleShading.",
2789 i);
John Zulauf7acac592017-11-06 11:15:53 -07002790 }
2791 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002792
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002793 const auto *line_state =
2794 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002795
2796 if (line_state) {
2797 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2798 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2799 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2800 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002801 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2802 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002803 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002804 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002805 }
2806 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2807 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002808 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2809 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002810 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002811 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002812 }
2813 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2814 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002815 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2816 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002817 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002818 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002819 }
2820 }
2821 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2822 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2823 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002824 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002825 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2826 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002827 "range [1,256].",
2828 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002829 }
2830 }
2831 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002832 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002833 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2834 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002835 skip |=
2836 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002837 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2838 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002839 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2840 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002841 }
2842 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2843 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002844 skip |=
2845 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002846 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2847 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002848 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2849 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002850 }
2851 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2852 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002853 skip |=
2854 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002855 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2856 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002857 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2858 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002859 }
2860 if (line_state->stippledLineEnable) {
2861 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2862 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002863 skip |=
2864 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002865 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2866 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002867 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2868 "stippledRectangularLines feature.",
2869 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002870 }
2871 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2872 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002873 skip |=
2874 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002875 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2876 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002877 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2878 "stippledBresenhamLines feature.",
2879 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002880 }
2881 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2882 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002883 skip |=
2884 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002885 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2886 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002887 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2888 "stippledSmoothLines feature.",
2889 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002890 }
2891 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05002892 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002893 skip |=
2894 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002895 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2896 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002897 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2898 "stippledRectangularLines and strictLines features.",
2899 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002900 }
2901 }
2902 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002903 }
2904
Petr Krause91f7a12017-12-14 20:57:36 +01002905 bool uses_color_attachment = false;
2906 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00002907 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01002908 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002909 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002910 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2911 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002912 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002913 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002914 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002915 }
2916 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002917 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002918 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00002919 subpass_flags = subpasses_uses.subpasses_flags[pCreateInfos[i].subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01002920 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002921 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002922 }
2923
2924 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002925 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002926 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002928 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002929 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002930
Mike Schuchardt00e81452021-11-29 11:11:20 -08002931 skip |=
2932 validate_flags("vkCreateGraphicsPipelines",
2933 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
2934 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
2935 pCreateInfos[i].pDepthStencilState->flags, kOptionalFlags,
2936 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002937
2938 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002939 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2941 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2942
2943 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002944 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002945 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2946 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2947
2948 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002949 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002950 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2951 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002952 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953
2954 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002955 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2957 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2958
2959 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002960 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2962 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2963
2964 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002965 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002966 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2967 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002968 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969
2970 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002971 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002972 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2973 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002974 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002975
2976 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002977 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002978 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2979 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002980 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981
2982 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002983 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2985 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002986 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987
2988 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002989 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002990 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2991 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002992 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002993
2994 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002995 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002996 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2997 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002998 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002999
3000 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003001 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003002 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
3003 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003004 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005
3006 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003007 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
3009 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003010 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011
3012 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003013 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003014 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3015 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003016 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3017 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003018 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003019
3020 if ((pCreateInfos[i].pDepthStencilState->flags &
3021 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3022 const auto *rasterization_order_attachment_access_feature =
3023 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3024 const bool rasterization_order_depth_attachment_access_feature_enabled =
3025 rasterization_order_attachment_access_feature &&
3026 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3027 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3028 skip |= LogError(
3029 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3030 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3031 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3032 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
3033 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str());
3034 }
3035
3036 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3037 skip |= LogError(
3038 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06468",
3039 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3040 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3041 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str(),
3042 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3043 }
3044 }
3045
3046 if ((pCreateInfos[i].pDepthStencilState->flags &
3047 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3048 const auto *rasterization_order_attachment_access_feature =
3049 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3050 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3051 rasterization_order_attachment_access_feature &&
3052 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3053 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3054 skip |= LogError(
3055 device,
3056 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3057 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3058 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3059 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
3060 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str());
3061 }
3062
3063 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3064 skip |= LogError(
3065 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06469",
3066 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3067 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3068 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str(),
3069 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3070 }
3071 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072 }
3073
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003074 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003075 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3076 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003077
Petr Krause91f7a12017-12-14 20:57:36 +01003078 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003079 skip |= validate_struct_type("vkCreateGraphicsPipelines",
3080 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3081 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3082 pCreateInfos[i].pColorBlendState,
3083 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
3084 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
3085
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003087 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003088 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02003089 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003090 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
3091 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003092 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3093 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003094
Mike Schuchardt00e81452021-11-29 11:11:20 -08003095 skip |= validate_flags("vkCreateGraphicsPipelines",
3096 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3097 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
3098 pCreateInfos[i].pColorBlendState->flags, kOptionalFlags,
3099 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003100
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003101 if ((pCreateInfos[i].pColorBlendState->flags &
3102 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3103 const auto *rasterization_order_attachment_access_feature =
3104 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3105 const bool rasterization_order_color_attachment_access_feature_enabled =
3106 rasterization_order_attachment_access_feature &&
3107 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3108
3109 if (!rasterization_order_color_attachment_access_feature_enabled) {
3110 skip |= LogError(
3111 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3112 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3113 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3114 "VkPipelineColorBlendStateCreateInfo::flags == %s",
3115 string_VkPipelineColorBlendStateCreateFlags(pCreateInfos[i].pColorBlendState->flags).c_str());
3116 }
3117
3118 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
3119 skip |= LogError(
3120 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06467",
3121 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3122 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3123 string_VkPipelineColorBlendStateCreateFlags(pCreateInfos[i].pColorBlendState->flags).c_str(),
3124 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3125 }
3126 }
3127
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003129 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003130 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
3131 pCreateInfos[i].pColorBlendState->logicOpEnable);
3132
3133 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003134 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003135 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3136 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00003137 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06003138 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139
3140 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003141 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
3142 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003143 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003145 ParameterName::IndexVector{i, attachment_index}),
3146 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147
3148 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003149 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003150 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003151 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003152 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003153 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003154 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003155
3156 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003157 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003159 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003161 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003162 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163
3164 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003165 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003166 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003167 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003169 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003170 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003171
3172 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003173 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003174 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003175 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003177 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003178 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003179
3180 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003181 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003183 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003184 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003185 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003186 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003187
3188 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003189 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003191 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003192 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003193 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003194 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003195
3196 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003197 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003198 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003199 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003200 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003201 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003202 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003203
3204 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3205 bool invalid = false;
3206 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3207 case VK_BLEND_OP_ZERO_EXT:
3208 case VK_BLEND_OP_SRC_EXT:
3209 case VK_BLEND_OP_DST_EXT:
3210 case VK_BLEND_OP_SRC_OVER_EXT:
3211 case VK_BLEND_OP_DST_OVER_EXT:
3212 case VK_BLEND_OP_SRC_IN_EXT:
3213 case VK_BLEND_OP_DST_IN_EXT:
3214 case VK_BLEND_OP_SRC_OUT_EXT:
3215 case VK_BLEND_OP_DST_OUT_EXT:
3216 case VK_BLEND_OP_SRC_ATOP_EXT:
3217 case VK_BLEND_OP_DST_ATOP_EXT:
3218 case VK_BLEND_OP_XOR_EXT:
3219 case VK_BLEND_OP_INVERT_EXT:
3220 case VK_BLEND_OP_INVERT_RGB_EXT:
3221 case VK_BLEND_OP_LINEARDODGE_EXT:
3222 case VK_BLEND_OP_LINEARBURN_EXT:
3223 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3224 case VK_BLEND_OP_LINEARLIGHT_EXT:
3225 case VK_BLEND_OP_PINLIGHT_EXT:
3226 case VK_BLEND_OP_HARDMIX_EXT:
3227 case VK_BLEND_OP_PLUS_EXT:
3228 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3229 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3230 case VK_BLEND_OP_PLUS_DARKER_EXT:
3231 case VK_BLEND_OP_MINUS_EXT:
3232 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3233 case VK_BLEND_OP_CONTRAST_EXT:
3234 case VK_BLEND_OP_INVERT_OVG_EXT:
3235 case VK_BLEND_OP_RED_EXT:
3236 case VK_BLEND_OP_GREEN_EXT:
3237 case VK_BLEND_OP_BLUE_EXT:
3238 invalid = true;
3239 break;
3240 default:
3241 break;
3242 }
3243 if (invalid) {
3244 skip |= LogError(
3245 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3246 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3247 "].pColorBlendState->pAttachments[%" PRIu32
3248 "].colorBlendOp (%s) is not valid when "
3249 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3250 "VK_FALSE",
3251 i, attachment_index,
3252 string_VkBlendOp(
3253 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3254 }
3255 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003256 }
3257 }
3258
3259 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003260 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003261 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3262 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003263 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3264 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003265 }
3266
3267 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3268 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3269 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003270 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003271 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003272 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3273 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003274 }
3275 }
3276 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003277
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003278 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3279 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003280 if (pCreateInfos[i].basePipelineIndex != -1) {
3281 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003282 skip |=
3283 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003284 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3285 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003286 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003287 "and pCreateInfos->basePipelineIndex is not -1.",
3288 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003289 }
3290 }
3291
Petr Kraus9752aae2017-11-24 03:05:50 +01003292 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3293 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003294 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003295 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3296 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003297 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003298 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3299 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003300 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003301 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003302 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003303 skip |=
3304 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003305 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3306 ") must be a valid"
3307 "index into the pCreateInfos array, of size %" PRIu32 ".",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003308 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003309 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003310 }
3311 }
3312
Petr Kraus9752aae2017-11-24 03:05:50 +01003313 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003314 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003315 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3316 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3318 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3319 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3320 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003321 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3322 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003323 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003324 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003325 "pCreateInfos[%" PRIu32
3326 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003327 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3328 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003329 }
3330 } else {
3331 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3332 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3333 (physical_device_features.fillModeNonSolid == false)) {
3334 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003335 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3336 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003337 "pCreateInfos[%" PRIu32
3338 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003339 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3340 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003341 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003342 }
Petr Kraus299ba622017-11-24 03:09:03 +01003343
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003344 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003345 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003346 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3347 "The line width state is static (pCreateInfos[%" PRIu32
3348 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3349 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3350 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3351 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003352 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003353 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003354
3355 // Validate no flags not allowed are used
3356 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003357 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003358 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3359 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003360 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3361 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003362 }
3363 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003364 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003365 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3366 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003367 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3368 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003369 }
3370 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3371 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003372 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3373 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003374 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3375 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003376 }
3377 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3378 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003379 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3380 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003381 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3382 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003383 }
3384 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3385 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003386 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3387 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003388 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3389 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003390 }
3391 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3392 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003393 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3394 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003395 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3396 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003397 }
3398 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3399 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003400 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3401 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003402 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3403 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003404 }
3405 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3406 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003407 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3408 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003409 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3410 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003411 }
3412 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3413 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003414 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3415 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003416 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3417 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003418 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003419 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3420 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3421 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3422 "]->flags (0x%x) must not include "
3423 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3424 i, flags);
3425 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426 }
3427 }
3428
3429 return skip;
3430}
3431
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003432bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3433 uint32_t createInfoCount,
3434 const VkComputePipelineCreateInfo *pCreateInfos,
3435 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003436 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003437 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003439 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003440 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003441 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003442 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003443 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003444 skip |=
3445 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3446 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3447 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3448 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003449 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003450
3451 // Make sure compute stage is selected
3452 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003453 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003454 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3455 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003456 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003457 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003458
sfricke-samsungeb549012021-04-16 01:25:51 -07003459 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3460 // Validate no flags not allowed are used
3461 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003462 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3463 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3464 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3465 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003466 }
3467 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3468 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003469 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3470 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003471 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3472 i, flags);
3473 }
3474 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3475 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003476 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3477 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003478 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3479 i, flags);
3480 }
3481 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3482 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003483 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3484 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003485 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3486 i, flags);
3487 }
3488 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3489 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003490 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3491 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003492 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3493 i, flags);
3494 }
3495 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3496 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003497 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3498 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003499 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3500 i, flags);
3501 }
3502 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3503 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003504 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3505 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003506 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3507 i, flags);
3508 }
3509 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3510 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003511 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3512 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003513 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3514 i, flags);
3515 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003516 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3517 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003518 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3519 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003520 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3521 i, flags);
3522 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003523 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3524 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003525 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3526 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003527 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3528 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003529 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003530 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3531 if (pCreateInfos[i].basePipelineIndex != -1) {
3532 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3533 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3534 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3535 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3536 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3537 i);
3538 }
3539 }
3540
3541 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3542 if (pCreateInfos[i].basePipelineIndex != -1) {
3543 skip |= LogError(
3544 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3545 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3546 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3547 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3548 i);
3549 }
3550 } else {
3551 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3552 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3553 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3554 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3555 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3556 }
3557 }
3558 }
ziga-lunargc6341372021-07-28 12:57:42 +02003559
3560 std::stringstream msg;
3561 msg << "pCreateInfos[%" << i << "].stage";
3562 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003563 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003564 return skip;
3565}
3566
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003567bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003568 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003569 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003570
3571 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003572 const auto &features = physical_device_features;
3573 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003574
John Zulauf71968502017-10-26 13:51:15 -06003575 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3576 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003577 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3578 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3579 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3580 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003581 }
3582
3583 // Anistropy cannot be enabled in sampler unless enabled as a feature
3584 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003585 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3586 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3587 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003588 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003589 }
John Zulauf71968502017-10-26 13:51:15 -06003590
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003591 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3592 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003593 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3594 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3595 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3596 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003597 }
3598 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003599 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3600 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3601 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3602 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003603 }
3604 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003605 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3606 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3607 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3608 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003609 }
3610 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3611 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3612 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3613 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003614 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3615 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3616 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3617 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3618 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3619 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003620 }
3621 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003622 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3623 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3624 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003625 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003626 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003627 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3628 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3629 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003630 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003631 }
3632
3633 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3634 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003635 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3636 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003637 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003638 if (sampler_reduction != nullptr) {
3639 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3640 skip |= LogError(
3641 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3642 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3643 }
3644 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003645 }
3646
3647 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3648 // valid VkBorderColor value
3649 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3650 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3651 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003652 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3653 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003654 }
3655
John Zulauf275805c2017-10-26 15:34:49 -06003656 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003657 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003658 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3659 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003660 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3661 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3662 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003663 }
3664 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003665
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003666 // Check for valid Lod range
3667 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003668 skip |=
3669 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3670 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003671 }
3672
3673 // Check mipLodBias to device limit
3674 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003675 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3676 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3677 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003678 }
3679
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003680 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003681 if (sampler_conversion != nullptr) {
3682 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3683 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3684 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3685 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003686 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003687 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003688 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3689 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3690 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3691 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3692 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3693 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3694 }
3695 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003696
3697 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3698 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3699 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3700 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3701 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3702 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3703 }
3704 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3705 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3706 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3707 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3708 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3709 }
3710 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3711 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3712 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3713 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3714 pCreateInfo->minLod, pCreateInfo->maxLod);
3715 }
3716 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3717 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3718 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3719 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3720 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3721 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3722 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3723 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3724 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3725 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3726 }
3727 if (pCreateInfo->anisotropyEnable) {
3728 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3729 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3730 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3731 }
3732 if (pCreateInfo->compareEnable) {
3733 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3734 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3735 "pCreateInfo->compareEnable must be VK_FALSE");
3736 }
3737 if (pCreateInfo->unnormalizedCoordinates) {
3738 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3739 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3740 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3741 }
3742 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003743
Piers Daniell833b9492021-11-20 11:47:10 -07003744 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3745 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3746 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3747 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3748 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3749 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3750 }
3751 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3752 if (!custom_create_info) {
3753 skip |= LogError(
3754 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3755 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3756 "struct in pNext chain.\n",
3757 string_VkBorderColor(pCreateInfo->borderColor));
3758 } else {
3759 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3760 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3761 !FormatIsSampledInt(custom_create_info->format)) ||
3762 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3763 !FormatIsSampledFloat(custom_create_info->format)))) {
3764 skip |=
3765 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003766 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3767 "whose type does not match\n",
3768 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003769 ;
3770 }
3771 }
3772 }
3773
3774 const auto *border_color_component_mapping =
3775 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3776 if (border_color_component_mapping) {
3777 const auto *border_color_swizzle_features =
3778 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
3779 bool border_color_swizzle_features_enabled =
3780 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
3781 if (!border_color_swizzle_features_enabled) {
3782 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
3783 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
3784 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06003785 }
3786 }
3787 }
3788
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003789 return skip;
3790}
3791
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003792bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3793 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3794 const char *func_name) const {
3795 bool skip = false;
3796
3797 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3798 uint32_t mutable_type_count = 0;
3799 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3800 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3801 }
3802 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3803 if (mutable_type_count == 0) {
3804 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3805 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3806 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3807 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3808 "].descriptorTypeCount is 0.",
3809 func_name, i, i);
3810 }
3811 } else {
3812 if (mutable_type_count > 0) {
3813 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3814 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3815 "].descriptorType is %s, but "
3816 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3817 "].descriptorTypeCount is not 0.",
3818 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3819 }
3820 }
3821 }
3822
3823 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3824 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3825 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3826 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3827 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
3828 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3829 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
3830 func_name, j, k);
3831 break;
3832 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
3833 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
3834 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3835 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
3836 func_name, j, k);
3837 break;
3838 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
3839 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
3840 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3841 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
3842 func_name, j, k);
3843 break;
3844 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
3845 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
3846 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3847 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
3848 func_name, j, k);
3849 break;
3850 default:
3851 break;
3852 }
3853 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
3854 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
3855 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
3856 skip |=
3857 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
3858 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3859 "].pDescriptorTypes[%" PRIu32
3860 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3861 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
3862 func_name, j, k, j, l,
3863 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
3864 }
3865 }
3866 }
3867 }
3868
3869 return skip;
3870}
3871
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003872bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3873 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3874 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003875 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003876 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003877
ziga-lunargfc6896f2021-10-15 18:46:12 +02003878 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
3879 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
3880 bool mutable_descriptor_type_features_enabled =
3881 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
3882
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003883 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3884 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3885 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3886 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003887 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3888 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3889 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3890 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3891 ++descriptor_index) {
3892 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003893 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003894 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003895 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
3896 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003897 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003898 }
3899 }
3900 }
3901
3902 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3903 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3904 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003905 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003906 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3907 "].descriptorCount is not 0, "
3908 "pCreateInfo->pBindings[%" PRIu32
3909 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003910 "values.",
3911 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003912 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003913
3914 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3915 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3916 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003917 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3918 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3919 "].descriptorCount is not 0 and "
3920 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
3921 "].stageFlags "
3922 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3923 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003924 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003925
3926 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3927 if (!mutable_descriptor_type) {
3928 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
3929 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3930 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3931 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
3932 i);
3933 }
3934 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
3935 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
3936 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3937 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3938 "pImmutableSamplers is not NULL.",
3939 i);
3940 }
3941 if (!mutable_descriptor_type_features_enabled) {
3942 skip |= LogError(
3943 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
3944 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3945 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3946 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
3947 i);
3948 }
3949 }
3950
3951 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
3952 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3953 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
3954 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3955 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
3956 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
3957 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003958 }
3959 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003960
3961 if (mutable_descriptor_type) {
3962 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
3963 "vkDescriptorSetLayoutCreateInfo");
3964 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003965 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003966 if (pCreateInfo) {
3967 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
3968 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3969 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
3970 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3971 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
3972 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3973 }
3974 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
3975 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3976 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
3977 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3978 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
3979 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3980 }
3981 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
3982 !mutable_descriptor_type_features_enabled) {
3983 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
3984 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3985 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
3986 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
3987 }
3988 }
3989
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003990 return skip;
3991}
3992
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003993bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3994 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003995 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003996 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3997 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3998 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003999 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
4000 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004001}
4002
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004003bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
4004 const VkWriteDescriptorSet *pDescriptorWrites,
4005 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004006 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004007
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004008 if (pDescriptorWrites != NULL) {
4009 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4010 // descriptorCount must be greater than 0
4011 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004012 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4013 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4014 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004015 }
4016
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004017 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
4018 if (validateDstSet) {
4019 // dstSet must be a valid VkDescriptorSet handle
4020 skip |= validate_required_handle(vkCallingFunction,
4021 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4022 pDescriptorWrites[i].dstSet);
4023 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004024
4025 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4026 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4027 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4028 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4029 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4030 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4031 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05004032 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
4033 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004034 if (pDescriptorWrites[i].pImageInfo == nullptr) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004035 skip |=
4036 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
4037 "%s(): if pDescriptorWrites[%" PRIu32
4038 "].descriptorType is "
4039 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4040 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4041 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4042 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004043 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4044 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004045 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4046 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004047 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4048 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004049 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004050 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4051 ParameterName::IndexVector{i, descriptor_index}),
4052 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004053 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004054 }
4055 }
4056 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4057 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4058 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4059 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4060 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4061 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4062 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004063 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004064 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004065 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004066 "%s(): if pDescriptorWrites[%" PRIu32
4067 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004068 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4069 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004070 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004071 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004072 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004073 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004074 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004075 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004076 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4077 ++descriptor_index) {
4078 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4079 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4080 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004081 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004082 "%s(): if pDescriptorWrites[%" PRIu32
4083 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004084 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004085 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4086 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004087 }
4088 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004089 }
4090 }
4091 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4092 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004093 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004094 }
4095
4096 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4097 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004098 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004099 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4100 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004101 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004102 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004103 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004104 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004105 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004106 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004107 }
4108 }
4109 }
4110 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4111 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004112 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004113 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4114 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004115 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004116 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004117 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004118 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004119 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004120 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004121 }
4122 }
4123 }
4124 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004125 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4126 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004127 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004128 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004129 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4130 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4131 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4132 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004133 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004134 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4135 pDescriptorWrites[i].descriptorCount);
4136 }
4137 // further checks only if we have right structtype
4138 if (pnext_struct) {
4139 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4140 skip |= LogError(
4141 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004142 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4143 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004144 ".",
4145 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004146 }
sourav parmarbcee7512020-12-28 14:34:49 -08004147 if (pnext_struct->accelerationStructureCount == 0) {
4148 skip |= LogError(device,
4149 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004150 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004151 }
4152 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004153 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004154 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4155 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4156 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4157 skip |= LogError(device,
4158 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4159 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004160 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004161 }
4162 }
4163 }
sourav parmarbcee7512020-12-28 14:34:49 -08004164 }
4165 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004166 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004167 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4168 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4169 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4170 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004171 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004172 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4173 pDescriptorWrites[i].descriptorCount);
4174 }
4175 // further checks only if we have right structtype
4176 if (pnext_struct) {
4177 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4178 skip |= LogError(
4179 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004180 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4181 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004182 ".",
4183 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004184 }
sourav parmarbcee7512020-12-28 14:34:49 -08004185 if (pnext_struct->accelerationStructureCount == 0) {
4186 skip |= LogError(device,
4187 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004188 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004189 }
4190 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004191 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004192 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4193 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4194 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4195 skip |= LogError(device,
4196 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4197 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004198 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004199 }
4200 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004201 }
4202 }
4203 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004204 }
4205 }
4206 return skip;
4207}
4208
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004209bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4210 const VkWriteDescriptorSet *pDescriptorWrites,
4211 uint32_t descriptorCopyCount,
4212 const VkCopyDescriptorSet *pDescriptorCopies) const {
4213 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
4214}
4215
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004216bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004217 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004218 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004219 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4220}
4221
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004222bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4223 const VkAllocationCallbacks *pAllocator,
4224 VkRenderPass *pRenderPass) const {
4225 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4226}
4227
Mike Schuchardt2df08912020-12-15 16:28:09 -08004228bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004229 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004230 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004231 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4232}
4233
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004234bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4235 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004236 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004237 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004238
4239 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4240 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4241 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004242 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4243 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004244 return skip;
4245}
4246
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004247bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004248 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004249 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004250
4251 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4252 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004253 bool cb_is_secondary;
4254 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004255 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004256 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4257 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004258
Tony-LunarG3c287f62020-12-17 12:39:49 -07004259 if (cb_is_secondary) {
4260 // Implicit VUs
4261 // validate only sType here; pointer has to be validated in core_validation
4262 const bool k_not_required = false;
4263 const char *k_no_vuid = nullptr;
4264 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4265 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004266 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4267 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004268
Tony-LunarG3c287f62020-12-17 12:39:49 -07004269 if (info) {
4270 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004271 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004272 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4273 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004274 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004275 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004276 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4277 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4278 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4279 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004280
Tony-LunarG3c287f62020-12-17 12:39:49 -07004281 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004282
Tony-LunarG3c287f62020-12-17 12:39:49 -07004283 // Explicit VUs
4284 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004285 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004286 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4287 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4288 cmd_name);
4289 }
4290
4291 if (physical_device_features.inheritedQueries) {
4292 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004293 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4294 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4295 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004296 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004297 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004298 }
4299
4300 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004301 skip |=
4302 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4303 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4304 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4305 } else { // !pipelineStatisticsQuery
4306 skip |=
4307 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4308 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004309 }
4310
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004311 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004312 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004313 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004314 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4315 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4316 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004317 commandBuffer,
4318 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004319 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4320 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4321 }
Petr Kraus139757b2019-08-15 17:19:33 +02004322 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004323
4324 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4325 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4326 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4327 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4328 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4329 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4330 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4331 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4332 }
Petr Kraus139757b2019-08-15 17:19:33 +02004333 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004334 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004335 return skip;
4336}
4337
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004338bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004339 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004340 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004341
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004342 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004343 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004344 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4345 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4346 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004347 }
4348 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004349 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4350 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4351 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004352 }
4353 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004354 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004355 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004356 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4357 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4358 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4359 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004360 }
4361 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004362
4363 if (pViewports) {
4364 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4365 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004366 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004367 skip |= manual_PreCallValidateViewport(
4368 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004369 }
4370 }
4371
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004372 return skip;
4373}
4374
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004375bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004376 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004377 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004378
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004379 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004380 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004381 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4382 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4383 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004384 }
4385 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004386 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4387 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4388 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004389 }
4390 } else { // multiViewport enabled
4391 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004392 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004393 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4394 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4395 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4396 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004397 }
4398 }
4399
Petr Kraus6260f0a2018-02-27 21:15:55 +01004400 if (pScissors) {
4401 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4402 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004403
Petr Kraus6260f0a2018-02-27 21:15:55 +01004404 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004405 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4406 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4407 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004408 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004409
Petr Kraus6260f0a2018-02-27 21:15:55 +01004410 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004411 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4412 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4413 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004414 }
4415
4416 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4417 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004418 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4419 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4420 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4421 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004422 }
4423
4424 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4425 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004426 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4427 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4428 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4429 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004430 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004431 }
4432 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004433
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004434 return skip;
4435}
4436
Jeff Bolz5c801d12019-10-09 10:38:45 -05004437bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004438 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004440 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004441 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4442 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004443 }
4444
4445 return skip;
4446}
4447
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004448bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004449 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004450 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004451
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004452 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004453 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004454 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4455 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004456 }
4457 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004458 skip |=
4459 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4460 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4461 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004462 }
4463 return skip;
4464}
4465
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004466bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004467 VkDeviceSize offset, uint32_t drawCount,
4468 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004469 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004470 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004471 skip |=
4472 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4473 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4474 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004475 }
4476 if (drawCount > device_limits.maxDrawIndirectCount) {
4477 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004478 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4479 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004480 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004481 }
4482 return skip;
4483}
4484
sfricke-samsungf692b972020-05-02 08:00:45 -07004485bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4486 VkDeviceSize countBufferOffset, bool khr) const {
4487 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004488 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004489 if (offset & 3) {
4490 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004491 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004492 }
4493
4494 if (countBufferOffset & 3) {
4495 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004496 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004497 countBufferOffset);
4498 }
4499 return skip;
4500}
4501
4502bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4503 VkDeviceSize offset, VkBuffer countBuffer,
4504 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4505 uint32_t stride) const {
4506 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4507}
4508
4509bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4510 VkDeviceSize offset, VkBuffer countBuffer,
4511 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4512 uint32_t stride) const {
4513 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4514}
4515
4516bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4517 VkDeviceSize countBufferOffset, bool khr) const {
4518 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004519 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004520 if (offset & 3) {
4521 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004522 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004523 }
4524
4525 if (countBufferOffset & 3) {
4526 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004527 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004528 countBufferOffset);
4529 }
4530 return skip;
4531}
4532
4533bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4534 VkDeviceSize offset, VkBuffer countBuffer,
4535 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4536 uint32_t stride) const {
4537 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4538}
4539
4540bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4541 VkDeviceSize offset, VkBuffer countBuffer,
4542 VkDeviceSize countBufferOffset,
4543 uint32_t maxDrawCount, uint32_t stride) const {
4544 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4545}
4546
Tony-LunarG4490de42021-06-21 15:49:19 -06004547bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4548 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4549 uint32_t firstInstance, uint32_t stride) const {
4550 bool skip = false;
4551 if (stride & 3) {
4552 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4553 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4554 }
4555 if (drawCount && nullptr == pVertexInfo) {
4556 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4557 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4558 "one or more valid instances of VkMultiDrawInfoEXT structures");
4559 }
4560 return skip;
4561}
4562
4563bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4564 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4565 uint32_t instanceCount, uint32_t firstInstance,
4566 uint32_t stride, const int32_t *pVertexOffset) const {
4567 bool skip = false;
4568 if (stride & 3) {
4569 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4570 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4571 }
4572 if (drawCount && nullptr == pIndexInfo) {
4573 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4574 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4575 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4576 }
4577 return skip;
4578}
4579
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004580bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4581 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004582 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004583 bool skip = false;
4584 for (uint32_t rect = 0; rect < rectCount; rect++) {
4585 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004586 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004587 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004588 }
sfricke-samsung10867682020-04-25 02:20:39 -07004589 if (pRects[rect].rect.extent.width == 0) {
4590 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004591 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004592 }
4593 if (pRects[rect].rect.extent.height == 0) {
4594 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004595 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004596 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004597 }
4598 return skip;
4599}
4600
Andrew Fobel3abeb992020-01-20 16:33:22 -05004601bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4602 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4603 VkImageFormatProperties2 *pImageFormatProperties,
4604 const char *apiName) const {
4605 bool skip = false;
4606
4607 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004608 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004609 if (image_stencil_struct != nullptr) {
4610 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4611 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4612 // No flags other than the legal attachment bits may be set
4613 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4614 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004615 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4616 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4617 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4618 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4619 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004620 }
4621 }
4622 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004623 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4624 if (image_drm_format) {
4625 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4626 skip |= LogError(
4627 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4628 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4629 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4630 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4631 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004632 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4633 skip |= LogError(
4634 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4635 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4636 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4637 apiName, image_drm_format->queueFamilyIndexCount);
4638 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004639 } else {
4640 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4641 skip |= LogError(
4642 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4643 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4644 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4645 apiName);
4646 }
4647 }
4648 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4649 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4650 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4651 if (!format_list || format_list->viewFormatCount == 0) {
4652 skip |= LogError(
4653 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4654 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4655 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4656 apiName);
4657 }
4658 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004659 }
4660
4661 return skip;
4662}
4663
4664bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4665 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4666 VkImageFormatProperties2 *pImageFormatProperties) const {
4667 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4668 "vkGetPhysicalDeviceImageFormatProperties2");
4669}
4670
4671bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4672 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4673 VkImageFormatProperties2 *pImageFormatProperties) const {
4674 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4675 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4676}
4677
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004678bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4679 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4680 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4681 bool skip = false;
4682
4683 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4684 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4685 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4686 }
4687
4688 return skip;
4689}
4690
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004691bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4692 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4693 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4694 bool skip = false;
4695
4696 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4697 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4698 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4699 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4700 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4701 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4702 }
4703
ziga-lunarg42f884b2021-08-25 16:13:20 +02004704 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004705}
4706
sfricke-samsung3999ef62020-02-09 17:05:59 -08004707bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4708 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4709 bool skip = false;
4710
4711 if (pRegions != nullptr) {
4712 for (uint32_t i = 0; i < regionCount; i++) {
4713 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004714 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004715 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004716 }
4717 }
4718 }
4719 return skip;
4720}
4721
Jeff Leger178b1e52020-10-05 12:22:23 -04004722bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4723 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4724 bool skip = false;
4725
4726 if (pCopyBufferInfo->pRegions != nullptr) {
4727 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4728 if (pCopyBufferInfo->pRegions[i].size == 0) {
4729 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004730 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004731 }
4732 }
4733 }
4734 return skip;
4735}
4736
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004737bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004738 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4739 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004740 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004741
4742 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004743 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4744 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4745 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004746 }
4747
4748 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004749 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4750 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4751 "), must be greater than zero and less than or equal to 65536.",
4752 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004753 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004754 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4755 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4756 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004757 }
4758 return skip;
4759}
4760
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004761bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004762 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004763 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004764
4765 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004766 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4767 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4768 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004769 }
4770
4771 if (size != VK_WHOLE_SIZE) {
4772 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004773 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004774 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4775 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004776 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004777 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4778 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004779 }
4780 }
4781 return skip;
4782}
4783
sfricke-samsunga1d00272021-03-10 21:37:41 -08004784bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004785 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004786
4787 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004788 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4789 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4790 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4791 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004792 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004793 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4794 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4795 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004796 }
4797
4798 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4799 // queueFamilyIndexCount uint32_t values
4800 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004801 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004802 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004803 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004804 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4805 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004806 }
4807 }
4808
Dave Houlton413a6782018-05-22 13:01:54 -06004809 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004810 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004811
sfricke-samsunga1d00272021-03-10 21:37:41 -08004812 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4813 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4814 if (format_list_info) {
4815 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4816 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4817 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4818 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004819 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4820 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004821 func_name, viewFormatCount);
4822 }
4823
4824 // Using the first format, compare the rest of the formats against it that they are compatible
4825 for (uint32_t i = 1; i < viewFormatCount; i++) {
4826 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4827 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4828 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4829 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004830 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4831 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004832 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4833 string_VkFormat(format_list_info->pViewFormats[i]));
4834 }
4835 }
4836 }
4837
4838 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4839 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4840 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4841 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4842 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4843 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4844 func_name);
4845 } else {
4846 if (format_list_info == nullptr) {
4847 skip |= LogError(
4848 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4849 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4850 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4851 func_name);
4852 } else if (format_list_info->viewFormatCount == 0) {
4853 skip |= LogError(
4854 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4855 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4856 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4857 func_name);
4858 } else {
4859 bool found_base_format = false;
4860 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4861 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4862 found_base_format = true;
4863 break;
4864 }
4865 }
4866 if (!found_base_format) {
4867 skip |=
4868 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4869 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4870 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4871 "pCreateInfo->imageFormat.",
4872 func_name);
4873 }
4874 }
4875 }
4876 }
4877 }
4878 return skip;
4879}
4880
4881bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4882 const VkAllocationCallbacks *pAllocator,
4883 VkSwapchainKHR *pSwapchain) const {
4884 bool skip = false;
4885 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4886 return skip;
4887}
4888
4889bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4890 const VkSwapchainCreateInfoKHR *pCreateInfos,
4891 const VkAllocationCallbacks *pAllocator,
4892 VkSwapchainKHR *pSwapchains) const {
4893 bool skip = false;
4894 if (pCreateInfos) {
4895 for (uint32_t i = 0; i < swapchainCount; i++) {
4896 std::stringstream func_name;
4897 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4898 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4899 }
4900 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004901 return skip;
4902}
4903
Jeff Bolz5c801d12019-10-09 10:38:45 -05004904bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004905 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004906
4907 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004908 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004909 if (present_regions) {
4910 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004911 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004912 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4913 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004914 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004915 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4916 "extension swapchainCount is %i. These values must be equal.",
4917 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004918 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004919 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004920 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4921 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004922 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4923 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4924 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004925 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004926 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004927 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004928 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004929 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004930 }
4931 }
4932
4933 return skip;
4934}
4935
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004936bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4937 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4938 const VkAllocationCallbacks *pAllocator,
4939 VkDisplayModeKHR *pMode) const {
4940 bool skip = false;
4941
4942 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4943 if (display_mode_parameters.visibleRegion.width == 0) {
4944 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4945 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4946 }
4947 if (display_mode_parameters.visibleRegion.height == 0) {
4948 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4949 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4950 }
4951 if (display_mode_parameters.refreshRate == 0) {
4952 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4953 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4954 }
4955
4956 return skip;
4957}
4958
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004959#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004960bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4961 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4962 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004963 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004964 bool skip = false;
4965
4966 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004967 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4968 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004969 }
4970
4971 return skip;
4972}
4973#endif // VK_USE_PLATFORM_WIN32_KHR
4974
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004975static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
4976 bool partial_overlap = false;
4977
4978 static const std::vector<VkDescriptorType> all_descriptor_types = {
4979 VK_DESCRIPTOR_TYPE_SAMPLER,
4980 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4981 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4982 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4983 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4984 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4985 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4986 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4987 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
4988 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
4989 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
4990 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
4991 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
4992 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
4993 };
4994
4995 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4996 if (mutable_descriptor_type) {
4997 std::vector<VkDescriptorType> first_types, second_types;
4998 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
4999 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5000 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5001 }
5002 } else {
5003 first_types = all_descriptor_types;
5004 }
5005 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5006 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5007 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5008 }
5009 } else {
5010 second_types = all_descriptor_types;
5011 }
5012
5013 bool complete_overlap = first_types.size() == second_types.size();
5014 bool disjoint = true;
5015 for (const auto first_type : first_types) {
5016 bool found = false;
5017 for (const auto second_type : second_types) {
5018 if (first_type == second_type) {
5019 found = true;
5020 break;
5021 }
5022 }
5023 if (found) {
5024 disjoint = false;
5025 } else {
5026 complete_overlap = false;
5027 }
5028 if (!disjoint && !complete_overlap) {
5029 partial_overlap = true;
5030 break;
5031 }
5032 }
5033 }
5034
5035 return partial_overlap;
5036}
5037
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005038bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005039 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005040 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005041 bool skip = false;
5042
5043 if (pCreateInfo) {
5044 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005045 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5046 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005047 }
5048
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005049 const auto *mutable_descriptor_type_features =
5050 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5051 bool mutable_descriptor_type_enabled =
5052 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5053
Petr Krausc8655be2017-09-27 18:56:51 +02005054 if (pCreateInfo->pPoolSizes) {
5055 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5056 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005057 skip |= LogError(
5058 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005059 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005060 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005061 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5062 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005063 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5064 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5065 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5066 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5067 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005068 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005069 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5070 skip |=
5071 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5072 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5073 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5074 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5075 i);
5076 }
5077 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5078 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5079 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5080 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5081 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5082 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5083 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5084 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5085 " and have sets which partially overlap.",
5086 i, j);
5087 }
5088 }
5089 }
5090 }
Petr Krausc8655be2017-09-27 18:56:51 +02005091 }
5092 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005093
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005094 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5095 skip |=
5096 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5097 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5098 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5099 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005100 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5101 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5102 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5103 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5104 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5105 }
Petr Krausc8655be2017-09-27 18:56:51 +02005106 }
5107
5108 return skip;
5109}
5110
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005111bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005112 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005113 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005114
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005115 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005116 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005117 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5118 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5119 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005120 }
5121
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005122 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005123 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005124 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5125 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5126 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005127 }
5128
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005129 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005130 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005131 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5132 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5133 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005134 }
5135
5136 return skip;
5137}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005138
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005139bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005140 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005141 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005142
5143 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005144 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5145 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005146 }
5147 return skip;
5148}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005149
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005150bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5151 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005152 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005153 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005154
5155 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005156 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005157 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005158 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5159 "vkCmdDispatch(): baseGroupX (%" PRIu32
5160 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5161 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005162 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005163 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5164 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5165 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5166 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005167 }
5168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005169 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005170 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005171 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5172 "vkCmdDispatch(): baseGroupY (%" PRIu32
5173 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5174 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005175 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005176 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5177 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5178 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5179 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005180 }
5181
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005182 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005183 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005184 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5185 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5186 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5187 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005188 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005189 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5190 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5191 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5192 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005193 }
5194
5195 return skip;
5196}
5197
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005198bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5199 VkPipelineBindPoint pipelineBindPoint,
5200 VkPipelineLayout layout, uint32_t set,
5201 uint32_t descriptorWriteCount,
5202 const VkWriteDescriptorSet *pDescriptorWrites) const {
5203 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
5204}
5205
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005206bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5207 uint32_t firstExclusiveScissor,
5208 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005209 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005210 bool skip = false;
5211
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005212 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005213 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005214 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005215 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5216 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5217 ") is not 0.",
5218 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005219 }
5220 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005221 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005222 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5223 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5224 ") is not 1.",
5225 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005226 }
5227 } else { // multiViewport enabled
5228 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005229 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005230 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5231 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5232 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5233 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005234 }
5235 }
5236
Jeff Bolz3e71f782018-08-29 23:15:45 -05005237 if (pExclusiveScissors) {
5238 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5239 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5240
5241 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005242 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5243 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5244 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005245 }
5246
5247 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005248 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5249 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5250 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005251 }
5252
5253 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5254 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005255 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5256 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5257 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5258 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005259 }
5260
5261 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5262 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005263 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5264 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5265 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5266 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005267 }
5268 }
5269 }
5270
5271 return skip;
5272}
5273
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005274bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5275 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005276 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005277 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005278 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5279 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5280 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5281 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5282 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5283 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005284 }
5285
5286 return skip;
5287}
5288
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005289bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5290 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005291 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005292 bool skip = false;
5293
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005294 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005295 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005296 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005297 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5298 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5299 ") is not 0.",
5300 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005301 }
5302 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005303 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005304 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5305 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5306 ") is not 1.",
5307 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005308 }
5309 }
5310
Jeff Bolz9af91c52018-09-01 21:53:57 -05005311 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005312 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005313 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5314 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5315 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5316 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005317 }
5318
5319 return skip;
5320}
5321
Jeff Bolz5c801d12019-10-09 10:38:45 -05005322bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5323 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5324 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005325 bool skip = false;
5326
Dave Houlton142c4cb2018-10-17 15:04:41 -06005327 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005328 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5329 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5330 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005331 }
5332
5333 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005334 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005335 }
5336
5337 return skip;
5338}
5339
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005340bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005341 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005342 bool skip = false;
5343
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005344 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005345 skip |= LogError(
5346 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005347 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5348 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005349 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005350 }
5351
5352 return skip;
5353}
5354
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005355bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5356 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005357 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005358 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005359 static const int condition_multiples = 0b0011;
5360 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005361 skip |= LogError(
5362 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005363 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005364 }
Lockee1c22882019-06-10 16:02:54 -06005365 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005366 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5367 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5368 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5369 stride);
Lockee1c22882019-06-10 16:02:54 -06005370 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005371 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005372 skip |= LogError(
5373 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005374 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5375 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005376 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005377 if (drawCount > device_limits.maxDrawIndirectCount) {
5378 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005379 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5380 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005381 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005382 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005383 return skip;
5384}
5385
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005386bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5387 VkDeviceSize offset, VkBuffer countBuffer,
5388 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005389 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005390 bool skip = false;
5391
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005392 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005393 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5394 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5395 "), is not a multiple of 4.",
5396 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005397 }
5398
5399 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005400 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5401 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5402 "), is not a multiple of 4.",
5403 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005404 }
5405
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005406 return skip;
5407}
5408
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005409bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005410 const VkAllocationCallbacks *pAllocator,
5411 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005412 bool skip = false;
5413
5414 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5415 if (pCreateInfo != nullptr) {
5416 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5417 // VkQueryPipelineStatisticFlagBits values
5418 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5419 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005420 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5421 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5422 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5423 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005424 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005425 if (pCreateInfo->queryCount == 0) {
5426 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5427 "vkCreateQueryPool(): queryCount must be greater than zero.");
5428 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005429 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005430 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005431}
5432
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005433bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5434 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005435 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005436 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5437 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005438}
5439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005440void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005441 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5442 VkResult result) {
5443 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005444 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005445}
5446
Mike Schuchardt2df08912020-12-15 16:28:09 -08005447void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005448 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5449 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005450 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005451 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005452 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005453}
5454
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005455void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5456 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005457 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005458 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005459 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005460}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005461
Tony-LunarG3c287f62020-12-17 12:39:49 -07005462void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005463 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005464 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005465 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005466 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005467 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005468 }
5469 }
5470}
5471
5472void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005473 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005474 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005475 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5476 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5477 }
5478}
5479
5480void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005481 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005482 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005483 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5484 if (item->second == commandPool) {
5485 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005486 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005487 ++item;
5488 }
5489 }
5490}
5491
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005492bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005493 const VkAllocationCallbacks *pAllocator,
5494 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005495 bool skip = false;
5496
5497 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005498 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005499 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005500 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5501 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005502 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005503
5504 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005505 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005506 if (flags_info) {
5507 flags = flags_info->flags;
5508 }
5509
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005510 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005511 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005512 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005513 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5514 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005515 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005516 }
5517
5518#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005519 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005520#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005521 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5522 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005523#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005524 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005525#endif
5526
5527 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005528 skip |= LogError(
5529 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005530 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5531 }
5532 if (
5533#ifdef VK_USE_PLATFORM_WIN32_KHR
5534 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5535#endif
5536 (import_memory_fd && import_memory_fd->handleType) ||
5537#ifdef VK_USE_PLATFORM_ANDROID_KHR
5538 (import_memory_ahb && import_memory_ahb->buffer) ||
5539#endif
5540 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005541 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5542 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005543 }
5544 }
5545
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005546 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5547 if (export_memory) {
5548 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5549 if (export_memory_nv) {
5550 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5551 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5552 "VkExportMemoryAllocateInfoNV");
5553 }
5554#ifdef VK_USE_PLATFORM_WIN32_KHR
5555 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5556 if (export_memory_win32_nv) {
5557 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5558 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5559 "VkExportMemoryWin32HandleInfoNV");
5560 }
5561#endif
5562 }
5563
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005564 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005565 VkBool32 capture_replay = false;
5566 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005567 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005568 if (vulkan_12_features) {
5569 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5570 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5571 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005572 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005573 if (bda_features) {
5574 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5575 buffer_device_address = bda_features->bufferDeviceAddress;
5576 }
5577 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005578 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005579 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005580 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005581 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005582 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005583 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005584 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005585 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005586 }
5587 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005588 }
5589 return skip;
5590}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005591
Jason Macnak192fa0e2019-07-26 15:07:16 -07005592bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005593 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005594 bool skip = false;
5595
5596 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5597 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5598 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005599 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005600 } else {
5601 uint32_t vertex_component_size = 0;
5602 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5603 vertex_component_size = 4;
5604 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5605 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5606 vertex_component_size = 2;
5607 }
5608 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005609 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005610 }
5611 }
5612
5613 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5614 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005615 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005616 } else {
5617 uint32_t index_element_size = 0;
5618 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5619 index_element_size = 4;
5620 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5621 index_element_size = 2;
5622 }
5623 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005624 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005625 }
5626 }
5627 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5628 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005629 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005630 }
5631 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005632 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005633 }
5634 }
5635
5636 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005637 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005638 }
5639
5640 return skip;
5641}
5642
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005643bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5644 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005645 bool skip = false;
5646
5647 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005648 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005649 }
5650 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005651 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005652 }
5653
5654 return skip;
5655}
5656
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005657bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5658 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005659 bool skip = false;
5660 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005661 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005662 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005663 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005664 }
5665 return skip;
5666}
5667
5668bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005669 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005670 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005671 bool skip = false;
5672 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005673 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5674 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5675 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005676 }
5677 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005678 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5679 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5680 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005681 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005682 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5683 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5684 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5685 }
Jason Macnak5c954952019-07-09 15:46:12 -07005686 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5687 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005688 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5689 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5690 "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 -07005691 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005692 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005693 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005694 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5695 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005696 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5697 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005698 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005699 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005700 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5701 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5702 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005703 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005704 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005705 uint64_t total_triangle_count = 0;
5706 for (uint32_t i = 0; i < info.geometryCount; i++) {
5707 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005708
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005709 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005710
Jason Macnak5c954952019-07-09 15:46:12 -07005711 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5712 continue;
5713 }
5714 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5715 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005716 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005717 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5718 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5719 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005720 }
5721 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005722 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5723 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5724 for (uint32_t i = 1; i < info.geometryCount; i++) {
5725 const VkGeometryNV &geometry = info.pGeometries[i];
5726 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005727 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005728 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5729 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005730 "info.pGeometries[0].geometryType.",
5731 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005732 }
5733 }
5734 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005735 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5736 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5737 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5738 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5739 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5740 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5741 }
5742 }
5743 skip |=
5744 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005745 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005746 return skip;
5747}
5748
Ricardo Garciaa4935972019-02-21 17:43:18 +01005749bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5750 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005751 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005752 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005753 if (pCreateInfo) {
5754 if ((pCreateInfo->compactedSize != 0) &&
5755 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005756 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5757 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5758 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5759 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005760 }
Jason Macnak5c954952019-07-09 15:46:12 -07005761
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005762 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005763 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005764 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005765 return skip;
5766}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005767
Jeff Bolz5c801d12019-10-09 10:38:45 -05005768bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5769 const VkAccelerationStructureInfoNV *pInfo,
5770 VkBuffer instanceData, VkDeviceSize instanceOffset,
5771 VkBool32 update, VkAccelerationStructureNV dst,
5772 VkAccelerationStructureNV src, VkBuffer scratch,
5773 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005774 bool skip = false;
5775
5776 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005777 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005778 }
5779
5780 return skip;
5781}
5782
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005783bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5784 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5785 VkAccelerationStructureKHR *pAccelerationStructure) const {
5786 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005787 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005788 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005789 if (!acceleration_structure_features ||
5790 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5791 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5792 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5793 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005794 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005795 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5796 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005797 (acceleration_structure_features &&
5798 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005799 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005800 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5801 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5802 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5803 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005804 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005805 if (pCreateInfo->deviceAddress &&
5806 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5807 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5808 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5809 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5810 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005811 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5812 (acceleration_structure_features &&
5813 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5814 skip |= LogError(
5815 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5816 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5817 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5818 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005819 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5820 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005821 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5822 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005823 }
sourav parmar83c31b12020-05-06 12:30:54 -07005824 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005825 return skip;
5826}
5827
Jason Macnak5c954952019-07-09 15:46:12 -07005828bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5829 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005830 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005831 bool skip = false;
5832 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005833 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5834 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005835 }
5836 return skip;
5837}
5838
sourav parmarcd5fb182020-07-17 12:58:44 -07005839bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5840 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5841 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5842 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005843 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005844 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005845 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005846 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005847 }
5848 return skip;
5849}
5850
Peter Chen85366392019-05-14 15:20:11 -04005851bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5852 uint32_t createInfoCount,
5853 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5854 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005855 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005856 bool skip = false;
5857
5858 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005859 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5860 std::stringstream msg;
5861 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5862 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5863 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005864 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005865 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005866 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005867 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5868 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5869 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5870 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005871 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005872
5873 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005874 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005875 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5876 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5877 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5878 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5879 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5880 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5881 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5882 }
5883 }
5884
sourav parmarf4a78252020-04-10 13:04:21 -07005885 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5886 skip |=
5887 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5888 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5889 }
5890 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5891 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5892 skip |=
5893 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5894 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5895 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5896 }
5897 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5898 if (pCreateInfos[i].basePipelineIndex != -1) {
5899 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5900 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5901 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5902 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5903 "and pCreateInfos->basePipelineIndex is not -1.");
5904 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005905 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005906 skip |=
5907 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5908 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5909 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5910 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5911 "that element.");
5912 }
sourav parmarf4a78252020-04-10 13:04:21 -07005913 }
5914 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005915 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005916 skip |=
5917 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5918 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5919 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5920 "commands pCreateInfos parameter.");
5921 }
5922 } else {
5923 if (pCreateInfos[i].basePipelineIndex != -1) {
5924 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5925 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5926 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5927 }
5928 }
5929 }
5930 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5931 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5932 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5933 }
5934 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5935 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5936 "vkCreateRayTracingPipelinesNV: flags must not include "
5937 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5938 }
5939 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5940 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5941 "vkCreateRayTracingPipelinesNV: flags must not include "
5942 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5943 }
5944 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5945 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5946 "vkCreateRayTracingPipelinesNV: flags must not include "
5947 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5948 }
5949 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5950 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5951 "vkCreateRayTracingPipelinesNV: flags must not include "
5952 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5953 }
5954 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5955 skip |= LogError(
5956 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5957 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5958 }
5959 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5960 skip |= LogError(
5961 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5962 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5963 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005964 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5965 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5966 "vkCreateRayTracingPipelinesNV: flags must not include "
5967 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5968 }
5969 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5970 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5971 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5972 }
ziga-lunargdfffee42021-10-10 11:49:59 +02005973 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
5974 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
5975 "vkCreateRayTracingPipelinesNV: flags must not contain the "
5976 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
5977 }
Peter Chen85366392019-05-14 15:20:11 -04005978 }
5979
5980 return skip;
5981}
5982
sourav parmarcd5fb182020-07-17 12:58:44 -07005983bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5984 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5985 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005986 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005987 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005988 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5989 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5990 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005991 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005992 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005993 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5994 std::stringstream msg;
5995 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5996 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5997 &pCreateInfos[i].pStages[i]);
5998 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005999 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6000 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6001 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6002 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6003 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6004 }
6005 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6006 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6007 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6008 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6009 }
6010 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006011 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006012 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
6013 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07006014 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6015 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6016 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006017 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6018 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6019 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006020 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006021 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006022 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6023 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6024 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6025 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006026 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006027 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6028 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6029 }
6030 }
sourav parmarf4a78252020-04-10 13:04:21 -07006031 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006032 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6033 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006034 }
6035 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006036 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006037 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006038 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6039 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006040 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006041 }
6042 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6043 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6044 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006045 }
6046 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6047 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6048 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6049 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6050 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6051 skip |= LogError(
6052 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006053 "vkCreateRayTracingPipelinesKHR: If flags includes "
6054 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006055 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6056 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6057 "must not be VK_SHADER_UNUSED_KHR");
6058 }
6059 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6060 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6061 skip |= LogError(
6062 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006063 "vkCreateRayTracingPipelinesKHR: If flags includes "
6064 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006065 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6066 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6067 "element must not be VK_SHADER_UNUSED_KHR");
6068 }
6069 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006070 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6071 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6072 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6073 skip |= LogError(
6074 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6075 "vkCreateRayTracingPipelinesKHR: If "
6076 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6077 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6078 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6079 }
6080 }
sourav parmarf4a78252020-04-10 13:04:21 -07006081 }
6082 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6083 if (pCreateInfos[i].basePipelineIndex != -1) {
6084 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6085 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006086 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006087 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6088 "and pCreateInfos->basePipelineIndex is not -1.");
6089 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006090 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006091 skip |=
6092 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6093 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6094 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6095 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6096 "element.");
6097 }
sourav parmarf4a78252020-04-10 13:04:21 -07006098 }
6099 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006100 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006101 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006102 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006103 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6104 ") must be a valid into the calling"
6105 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006106 pCreateInfos[i].basePipelineIndex, createInfoCount);
6107 }
6108 } else {
6109 if (pCreateInfos[i].basePipelineIndex != -1) {
6110 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006111 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006112 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6113 }
6114 }
6115 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006116 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6117 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6118 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6119 "vkCreateRayTracingPipelinesKHR: If flags includes "
6120 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6121 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006122 }
6123 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6124 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6125 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6126 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6127 "pLibraryInfo and pLibraryInterface must be NULL.");
6128 }
6129 if (pCreateInfos[i].pLibraryInfo) {
6130 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6131 if (pCreateInfos[i].stageCount == 0) {
6132 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6133 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6134 "stageCount must not be 0.");
6135 }
6136 if (pCreateInfos[i].groupCount == 0) {
6137 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6138 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6139 "groupCount must not be 0.");
6140 }
6141 } else {
6142 if (pCreateInfos[i].pLibraryInterface == NULL) {
6143 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6144 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6145 "is greater than 0, its "
6146 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006147 }
6148 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006149 }
6150 if (pCreateInfos[i].pLibraryInterface) {
6151 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6152 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6153 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6154 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6155 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6156 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006157 }
6158 if (deferredOperation != VK_NULL_HANDLE) {
6159 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6160 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6161 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6162 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006163 }
6164 }
ziga-lunargdea76582021-09-17 14:38:08 +02006165 if (pCreateInfos[i].pDynamicState) {
6166 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6167 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6168 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6169 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6170 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6171 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6172 }
6173 }
6174 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006175 }
6176
6177 return skip;
6178}
6179
Mike Schuchardt21638df2019-03-16 10:52:02 -07006180#ifdef VK_USE_PLATFORM_WIN32_KHR
6181bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6182 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006183 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006184 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006185 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006186 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006187 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006188 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006189 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006190 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006191 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006192 skip |=
6193 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006194 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006195 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6196 skip |= validate_struct_type(
6197 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6198 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6199 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6200 if (pSurfaceInfo != NULL) {
6201 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6202 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6203 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6204
6205 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6206 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6207 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6208 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006209 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6210 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006211
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006212 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6213 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6214 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6215 "VK_GOOGLE_surfaceless_query is not enabled.");
6216 }
6217
Mike Schuchardt21638df2019-03-16 10:52:02 -07006218 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6219 }
6220 return skip;
6221}
6222#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006223
6224bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6225 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006226 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006227 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6228 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006229 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006230 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6231 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6232 }
6233 return skip;
6234}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006235
6236bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006237 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006238 bool skip = false;
6239
6240 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006241 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006242 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006243 }
6244
6245 return skip;
6246}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006247
6248bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006249 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006250 bool skip = false;
6251
6252 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006253 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6254 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006255 }
6256
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006257 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006258 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006259 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6260 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006261 }
6262
6263 return skip;
6264}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006265
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006266bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6267 uint32_t bindingCount, const VkBuffer *pBuffers,
6268 const VkDeviceSize *pOffsets) const {
6269 bool skip = false;
6270 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006271 skip |=
6272 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6273 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6274 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006275 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6276 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006277 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6278 ") must be less than "
6279 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006280 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6281 }
6282
Jeff Bolz165818a2020-05-08 11:19:03 -05006283 for (uint32_t i = 0; i < bindingCount; ++i) {
6284 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006285 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006286 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006287 skip |=
6288 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6289 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006290 } else {
6291 if (pOffsets[i] != 0) {
6292 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006293 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6294 "] is not 0",
6295 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006296 }
6297 }
6298 }
6299 }
6300
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006301 return skip;
6302}
6303
Mark Lobodzinski84988402019-09-11 15:27:30 -06006304bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006305 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006306 bool skip = false;
6307 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006308 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6309 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006310 }
6311 return skip;
6312}
6313
6314bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006315 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006316 bool skip = false;
6317 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006318 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6319 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006320 }
6321 return skip;
6322}
Petr Kraus3d720392019-11-13 02:52:39 +01006323
6324bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6325 VkSemaphore semaphore, VkFence fence,
6326 uint32_t *pImageIndex) const {
6327 bool skip = false;
6328
6329 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006330 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6331 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006332 }
6333
6334 return skip;
6335}
6336
6337bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6338 uint32_t *pImageIndex) const {
6339 bool skip = false;
6340
6341 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006342 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6343 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006344 }
6345
6346 return skip;
6347}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006348
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006349bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6350 uint32_t firstBinding, uint32_t bindingCount,
6351 const VkBuffer *pBuffers,
6352 const VkDeviceSize *pOffsets,
6353 const VkDeviceSize *pSizes) const {
6354 bool skip = false;
6355
6356 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6357 for (uint32_t i = 0; i < bindingCount; ++i) {
6358 if (pOffsets[i] & 3) {
6359 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6360 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6361 }
6362 }
6363
6364 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6365 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6366 "%s: The firstBinding(%" PRIu32
6367 ") index is greater than or equal to "
6368 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6369 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6370 }
6371
6372 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6373 skip |=
6374 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6375 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6376 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6377 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6378 }
6379
6380 for (uint32_t i = 0; i < bindingCount; ++i) {
6381 // pSizes is optional and may be nullptr.
6382 if (pSizes != nullptr) {
6383 if (pSizes[i] != VK_WHOLE_SIZE &&
6384 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6385 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6386 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6387 ") is not VK_WHOLE_SIZE and is greater than "
6388 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6389 cmd_name, i, pSizes[i]);
6390 }
6391 }
6392 }
6393
6394 return skip;
6395}
6396
6397bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6398 uint32_t firstCounterBuffer,
6399 uint32_t counterBufferCount,
6400 const VkBuffer *pCounterBuffers,
6401 const VkDeviceSize *pCounterBufferOffsets) const {
6402 bool skip = false;
6403
6404 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6405 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6406 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6407 "%s: The firstCounterBuffer(%" PRIu32
6408 ") index is greater than or equal to "
6409 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6410 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6411 }
6412
6413 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6414 skip |=
6415 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6416 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6417 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6418 cmd_name, firstCounterBuffer, counterBufferCount,
6419 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6420 }
6421
6422 return skip;
6423}
6424
6425bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6426 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6427 const VkBuffer *pCounterBuffers,
6428 const VkDeviceSize *pCounterBufferOffsets) const {
6429 bool skip = false;
6430
6431 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6432 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6433 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6434 "%s: The firstCounterBuffer(%" PRIu32
6435 ") index is greater than or equal to "
6436 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6437 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6438 }
6439
6440 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6441 skip |=
6442 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6443 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6444 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6445 cmd_name, firstCounterBuffer, counterBufferCount,
6446 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6447 }
6448
6449 return skip;
6450}
6451
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006452bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6453 uint32_t firstInstance, VkBuffer counterBuffer,
6454 VkDeviceSize counterBufferOffset,
6455 uint32_t counterOffset, uint32_t vertexStride) const {
6456 bool skip = false;
6457
6458 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006459 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6460 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6461 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6462 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006463 }
6464
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006465 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006466 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006467 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006468 }
6469
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006470 return skip;
6471}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006472
6473bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6474 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6475 const VkAllocationCallbacks *pAllocator,
6476 VkSamplerYcbcrConversion *pYcbcrConversion,
6477 const char *apiName) const {
6478 bool skip = false;
6479
6480 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006481 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006482 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006483 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006484 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6485 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006486 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006487 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006488 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006489
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006490#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006491 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006492 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006493#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006494 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006495#endif
6496
sfricke-samsung1a72f942020-07-25 12:09:18 -07006497 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006498
6499 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006500 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006501 const VkComponentMapping components = pCreateInfo->components;
6502 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6503 if (FormatIsXChromaSubsampled(format) == true) {
6504 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6505 skip |=
6506 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006507 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6508 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006509 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006510 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006511
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006512 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6513 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6514 skip |= LogError(
6515 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6516 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6517 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6518 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6519 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006520
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006521 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6522 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6523 skip |=
6524 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006525 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6526 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006527 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006528 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006529
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006530 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6531 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6532 skip |=
6533 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006534 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6535 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006536 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006537 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006538
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006539 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006540 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6541 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6542 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006543 skip |=
6544 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006545 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6546 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006547 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6548 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006549 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006550 }
6551
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006552 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6553 // Checks same VU multiple ways in order to give a more useful error message
6554 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6555 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6556 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6557 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6558 skip |= LogError(
6559 device, vuid,
6560 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6561 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6562 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6563 string_VkComponentSwizzle(components.b));
6564 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006565
sfricke-samsunged028b02021-09-06 23:14:51 -07006566 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6567 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006568 // 3 = no [a]
6569 // 2 = no [b,a]
6570 // 1 = no [g,b,a]
6571 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006572 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006573
sfricke-samsunged028b02021-09-06 23:14:51 -07006574 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6575 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006576 skip |= LogError(device, vuid,
6577 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6578 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6579 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6580 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006581 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006582 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6583 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6584 skip |= LogError(device, vuid,
6585 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6586 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6587 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6588 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6589 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006590 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006591 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6592 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6593 skip |= LogError(device, vuid,
6594 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6595 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6596 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6597 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6598 string_VkComponentSwizzle(components.b));
6599 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006600 }
6601 }
6602
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006603 return skip;
6604}
6605
6606bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6607 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6608 const VkAllocationCallbacks *pAllocator,
6609 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6610 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6611 "vkCreateSamplerYcbcrConversion");
6612}
6613
6614bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6615 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6616 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6617 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6618 "vkCreateSamplerYcbcrConversionKHR");
6619}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006620
6621bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6622 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6623 bool skip = false;
6624 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6625 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6626
6627 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006628 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6629 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6630 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6631 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6632 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006633 }
6634 return skip;
6635}
sourav parmara96ab1a2020-04-25 16:28:23 -07006636
6637bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006638 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006639 bool skip = false;
6640 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6641 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6642 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6643 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006644 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006645 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6646 skip |= LogError(
6647 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6648 "vkCopyAccelerationStructureToMemoryKHR: The "
6649 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6650 }
6651 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6652 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6653 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6654 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6655 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6656 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006657 return skip;
6658}
6659
6660bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6661 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6662 bool skip = false;
6663 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6664 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6665 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6666 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6667 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006668 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6669 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006670 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006671 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006672 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006673 return skip;
6674}
6675
6676bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6677 const char *api_name) const {
6678 bool skip = false;
6679 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6680 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6681 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6682 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6683 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6684 api_name);
6685 }
6686 return skip;
6687}
6688
6689bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006690 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006691 bool skip = false;
6692 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006693 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006694 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006695 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006696 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6697 "vkCopyAccelerationStructureKHR: The "
6698 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006699 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006700 return skip;
6701}
6702
6703bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6704 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6705 bool skip = false;
6706 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6707 return skip;
6708}
6709
6710bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006711 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006712 bool skip = false;
6713 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006714 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006715 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6716 }
6717 return skip;
6718}
6719
6720bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006721 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006722 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006723 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006724 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006725 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6726 skip |= LogError(
6727 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6728 "vkCopyMemoryToAccelerationStructureKHR: The "
6729 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006730 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006731 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6732 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006733 return skip;
6734}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006735
sourav parmara96ab1a2020-04-25 16:28:23 -07006736bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6737 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6738 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006739 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006740 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6741 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006742 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006743 pInfo->src.deviceAddress);
6744 }
sourav parmar83c31b12020-05-06 12:30:54 -07006745 return skip;
6746}
6747bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6748 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6749 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6750 bool skip = false;
6751 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6752 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6753 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6754 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6755 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6756 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6757 }
6758 return skip;
6759}
6760bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6761 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6762 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6763 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006764 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006765 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6766 skip |= LogError(
6767 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6768 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6769 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6770 }
sourav parmar83c31b12020-05-06 12:30:54 -07006771 if (dataSize < accelerationStructureCount * stride) {
6772 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6773 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006774 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006775 dataSize, accelerationStructureCount, stride);
6776 }
6777 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6778 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6779 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6780 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6781 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6782 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6783 }
6784 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6785 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6786 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6787 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6788 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6789 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6790 stride);
6791 }
6792 }
6793 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6794 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6795 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6796 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6797 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6798 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6799 stride);
6800 }
6801 }
sourav parmar83c31b12020-05-06 12:30:54 -07006802 return skip;
6803}
6804bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6805 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6806 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006807 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006808 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6809 skip |= LogError(
6810 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6811 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6812 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006813 }
6814 return skip;
6815}
6816
6817bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006818 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6819 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6820 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6821 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006822 uint32_t width, uint32_t height, uint32_t depth) const {
6823 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006824 // RayGen
6825 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6826 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6827 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006828 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006829 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6830 0) {
6831 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6832 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6833 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6834 }
6835 // Callable
6836 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6837 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6838 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6839 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006840 }
6841 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6842 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6843 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006844 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6845 }
6846 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6847 0) {
6848 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6849 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6850 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006851 }
6852 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006853 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6854 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6855 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6856 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006857 }
6858 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6859 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006860 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6861 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006862 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006863 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6864 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6865 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6866 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6867 }
sourav parmar83c31b12020-05-06 12:30:54 -07006868 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006869 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6870 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6871 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6872 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006873 }
6874 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6875 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6876 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006877 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6878 }
6879 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6880 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6881 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6882 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6883 }
6884 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6885 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6886 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6887 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6888 }
6889 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6890 skip |=
6891 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6892 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6893 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006894 }
6895
sourav parmarcd5fb182020-07-17 12:58:44 -07006896 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6897 skip |=
6898 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6899 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6900 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6901 }
6902
6903 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6904 skip |=
6905 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6906 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6907 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006908 }
6909 return skip;
6910}
6911
sourav parmarcd5fb182020-07-17 12:58:44 -07006912bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6913 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6914 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6915 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006916 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006917 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006918 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6919 skip |= LogError(
6920 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6921 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6922 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006923 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006924 // RayGen
6925 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6926 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6927 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006928 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006929 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6930 0) {
6931 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6932 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6933 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6934 }
6935 // Callabe
6936 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6937 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6938 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6939 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006940 }
6941 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6942 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006943 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6944 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6945 }
6946 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6947 0) {
6948 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6949 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6950 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006951 }
6952 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006953 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6954 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6955 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6956 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006957 }
6958 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6959 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006960 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6961 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006962 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006963 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6964 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6965 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6966 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6967 }
sourav parmar83c31b12020-05-06 12:30:54 -07006968 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006969 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6970 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6971 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6972 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006973 }
6974 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6975 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006976 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6977 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6978 }
6979 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6980 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6981 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6982 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006983 }
6984
sourav parmarcd5fb182020-07-17 12:58:44 -07006985 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6986 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6987 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006988 }
6989 return skip;
6990}
6991bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6992 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6993 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6994 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6995 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6996 uint32_t width, uint32_t height, uint32_t depth) const {
6997 bool skip = false;
6998 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6999 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7000 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7001 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7002 }
7003 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7004 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7005 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7006 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7007 }
7008 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7009 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7010 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7011 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7012 }
7013
7014 // hitShader
7015 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7016 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7017 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7018 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7019 }
7020 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7021 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7022 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7023 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7024 }
7025 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7026 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7027 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7028 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7029 }
7030
7031 // missShader
7032 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7033 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7034 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7035 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7036 }
7037 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7038 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7039 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7040 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7041 }
7042 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7043 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7044 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7045 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7046 }
7047
7048 // raygenShader
7049 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7050 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7051 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007052 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7053 }
7054 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7055 skip |=
7056 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7057 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7058 }
7059 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7060 skip |=
7061 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7062 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7063 }
7064 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7065 skip |=
7066 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7067 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007068 }
7069 return skip;
7070}
7071
sourav parmar83c31b12020-05-06 12:30:54 -07007072bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007073 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7074 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007075 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007076 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7077 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007078 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7079 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007080 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007081 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7082 }
7083 return skip;
7084}
7085
Piers Daniell39842ee2020-07-10 16:42:33 -06007086bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7087 const VkViewport *pViewports) const {
7088 bool skip = false;
7089
7090 if (!physical_device_features.multiViewport) {
7091 if (viewportCount != 1) {
7092 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
7093 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
7094 ") is not 1.",
7095 viewportCount);
7096 }
7097 } else { // multiViewport enabled
7098 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
7099 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
7100 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
7101 ") must "
7102 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
7103 viewportCount, device_limits.maxViewports);
7104 }
7105 }
7106
7107 if (pViewports) {
7108 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7109 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
7110 const char *fn_name = "vkCmdSetViewportWithCountEXT";
7111 skip |= manual_PreCallValidateViewport(
7112 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
7113 }
7114 }
7115
7116 return skip;
7117}
7118
7119bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7120 const VkRect2D *pScissors) const {
7121 bool skip = false;
7122
7123 if (!physical_device_features.multiViewport) {
7124 if (scissorCount != 1) {
7125 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
7126 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7127 ") must "
7128 "be 1 when the multiViewport feature is disabled.",
7129 scissorCount);
7130 }
7131 } else { // multiViewport enabled
7132 if (scissorCount == 0) {
7133 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7134 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7135 ") must "
7136 "be great than zero.",
7137 scissorCount);
7138 } else if (scissorCount > device_limits.maxViewports) {
7139 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7140 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7141 ") must "
7142 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
7143 scissorCount, device_limits.maxViewports);
7144 }
7145 }
7146
7147 if (pScissors) {
7148 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7149 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7150
7151 if (scissor.offset.x < 0) {
7152 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7153 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
7154 scissor.offset.x);
7155 }
7156
7157 if (scissor.offset.y < 0) {
7158 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7159 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
7160 scissor.offset.y);
7161 }
7162
7163 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7164 if (x_sum > INT32_MAX) {
7165 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
7166 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7167 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7168 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
7169 }
7170
7171 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7172 if (y_sum > INT32_MAX) {
7173 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
7174 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7175 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7176 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7177 }
7178 }
7179 }
7180
7181 return skip;
7182}
7183
7184bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7185 uint32_t bindingCount, const VkBuffer *pBuffers,
7186 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7187 const VkDeviceSize *pStrides) const {
7188 bool skip = false;
7189 if (firstBinding >= device_limits.maxVertexInputBindings) {
7190 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007191 "vkCmdBindVertexBuffers2EXT() firstBinding (%" PRIu32
7192 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007193 firstBinding, device_limits.maxVertexInputBindings);
7194 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7195 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007196 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7197 ") must be less than "
7198 "maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007199 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7200 }
7201
7202 for (uint32_t i = 0; i < bindingCount; ++i) {
7203 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007204 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06007205 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007206 skip |= LogError(
7207 commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
7208 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007209 } else {
7210 if (pOffsets[i] != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007211 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
7212 "vkCmdBindVertexBuffers2EXT() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
7213 "] is not 0",
7214 i, i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007215 }
7216 }
7217 }
7218 if (pStrides) {
7219 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007220 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
7221 "vkCmdBindVertexBuffers2EXT() pStrides[%" PRIu32 "] (%" PRIu64
7222 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7223 i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007224 }
7225 }
7226 }
7227
7228 return skip;
7229}
sourav parmarcd5fb182020-07-17 12:58:44 -07007230
7231bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7232 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7233 bool skip = false;
7234 for (uint32_t i = 0; i < infoCount; ++i) {
7235 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7236 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7237 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7238 }
7239 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7240 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7241 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7242 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7243 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7244 api_name);
7245 }
7246 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7247 skip |=
7248 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7249 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7250 }
7251 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7252 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7253 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7254 }
7255 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7256 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7257 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7258 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7259 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7260 api_name);
7261 }
7262 if (pInfos[i].pGeometries) {
7263 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7264 skip |= validate_ranged_enum(
7265 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7266 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7267 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7268 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007269 skip |= validate_struct_type(
7270 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7271 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7272 &(pInfos[i].pGeometries[j].geometry.triangles),
7273 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7274 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7275 skip |= validate_struct_pnext(
7276 api_name,
7277 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7278 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7279 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7280 skip |=
7281 validate_ranged_enum(api_name,
7282 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7283 ParameterName::IndexVector{i, j}),
7284 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7285 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7286 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7287 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7288 &pInfos[i].pGeometries[j].geometry.triangles,
7289 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7290 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7291 skip |= validate_ranged_enum(
7292 api_name,
7293 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7294 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7295 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7296
7297 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7298 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7299 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7300 }
7301 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7302 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7303 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7304 skip |=
7305 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7306 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7307 api_name);
7308 }
7309 }
7310 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7311 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7312 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7313 &pInfos[i].pGeometries[j].geometry.instances,
7314 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7315 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7316 skip |= validate_struct_type(
7317 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7318 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7319 &(pInfos[i].pGeometries[j].geometry.instances),
7320 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7321 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7322 skip |= validate_struct_pnext(
7323 api_name,
7324 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7325 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7326 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7327
7328 skip |= validate_bool32(api_name,
7329 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7330 ParameterName::IndexVector{i, j}),
7331 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7332 }
7333 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7334 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7335 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7336 &pInfos[i].pGeometries[j].geometry.aabbs,
7337 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7338 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7339 skip |= validate_struct_type(
7340 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7341 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7342 &(pInfos[i].pGeometries[j].geometry.aabbs),
7343 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7344 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7345 skip |= validate_struct_pnext(
7346 api_name,
7347 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7348 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7349 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7350 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7351 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7352 "(%s):stride must be less than or equal to 2^32-1", api_name);
7353 }
7354 }
7355 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7356 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7357 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7358 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7359 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7360 api_name);
7361 }
7362 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7363 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7364 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7365 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7366 "of elements of"
7367 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7368 api_name);
7369 }
7370 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7371 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7372 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7373 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7374 api_name);
7375 }
7376 }
7377 }
7378 }
7379 if (pInfos[i].ppGeometries != NULL) {
7380 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7381 skip |= validate_ranged_enum(
7382 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7383 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7384 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7385 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007386 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7387 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7388 &pInfos[i].ppGeometries[j]->geometry.triangles,
7389 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7390 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7391 skip |= validate_struct_type(
7392 api_name,
7393 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7394 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7395 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7396 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7397 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7398 skip |= validate_struct_pnext(
7399 api_name,
7400 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7401 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7402 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7403 skip |= validate_ranged_enum(api_name,
7404 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7405 ParameterName::IndexVector{i, j}),
7406 "VkFormat", AllVkFormatEnums,
7407 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7408 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7409 skip |= validate_ranged_enum(api_name,
7410 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7411 ParameterName::IndexVector{i, j}),
7412 "VkIndexType", AllVkIndexTypeEnums,
7413 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7414 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7415 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7416 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7417 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7418 }
7419 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7420 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7421 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7422 skip |=
7423 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7424 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7425 api_name);
7426 }
7427 }
7428 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7429 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7430 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7431 &pInfos[i].ppGeometries[j]->geometry.instances,
7432 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7433 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7434 skip |= validate_struct_type(
7435 api_name,
7436 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7437 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7438 &(pInfos[i].ppGeometries[j]->geometry.instances),
7439 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7440 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7441 skip |= validate_struct_pnext(
7442 api_name,
7443 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7444 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7445 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7446 skip |= validate_bool32(api_name,
7447 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7448 ParameterName::IndexVector{i, j}),
7449 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7450 }
7451 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7452 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7453 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7454 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7455 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7456 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7457 skip |= validate_struct_type(
7458 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7459 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7460 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7461 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7462 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7463 skip |= validate_struct_pnext(
7464 api_name,
7465 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7466 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7467 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7468 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7469 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7470 "(%s):stride must be less than or equal to 2^32-1", api_name);
7471 }
7472 }
7473 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7474 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7475 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7476 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7477 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7478 api_name);
7479 }
7480 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7481 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7482 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7483 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7484 "of elements of"
7485 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7486 api_name);
7487 }
7488 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7489 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7490 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7491 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7492 api_name);
7493 }
7494 }
7495 }
7496 }
7497 }
7498 return skip;
7499}
7500bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7501 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7502 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7503 bool skip = false;
7504 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7505 for (uint32_t i = 0; i < infoCount; ++i) {
7506 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7507 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7508 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7509 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7510 "scratchData.deviceAddress member must be a multiple of "
7511 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7512 }
7513 for (uint32_t k = 0; k < infoCount; ++k) {
7514 if (i == k) continue;
7515 bool found = false;
7516 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007517 skip |=
7518 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7519 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7520 ") of pInfos must "
7521 "not be "
7522 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7523 ") of pInfos.",
7524 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007525 found = true;
7526 }
7527 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007528 skip |=
7529 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7530 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7531 ") of pInfos must "
7532 "not be "
7533 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7534 ") of pInfos.",
7535 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007536 found = true;
7537 }
7538 if (found) break;
7539 }
7540 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7541 if (pInfos[i].pGeometries) {
7542 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7543 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7544 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7545 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7546 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7547 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7548 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7549 }
7550 } else {
7551 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7552 skip |=
7553 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7554 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7555 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7556 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7557 }
7558 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007559 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007560 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7561 skip |= LogError(
7562 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7563 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7564 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7565 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007566 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7567 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007568 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7569 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7570 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7571 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7572 }
7573 }
7574 } else if (pInfos[i].ppGeometries) {
7575 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7576 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7577 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7578 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7579 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7580 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7581 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7582 }
7583 } else {
7584 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7585 skip |=
7586 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7587 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7588 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7589 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7590 }
7591 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007592 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007593 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7594 skip |= LogError(
7595 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7596 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7597 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7598 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007599 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7600 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007601 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7602 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7603 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7604 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7605 }
7606 }
7607 }
7608 }
7609 }
7610 return skip;
7611}
7612
7613bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7614 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7615 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7616 const uint32_t *const *ppMaxPrimitiveCounts) const {
7617 bool skip = false;
7618 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7619 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007620 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007621 if (!ray_tracing_acceleration_structure_features ||
7622 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7623 skip |= LogError(
7624 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7625 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7626 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7627 }
7628 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007629 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7630 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7631 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7632 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7633 "scratchData.deviceAddress member must be a multiple of "
7634 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7635 }
7636 for (uint32_t k = 0; k < infoCount; ++k) {
7637 if (i == k) continue;
7638 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007639 skip |= LogError(
7640 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7641 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7642 ") "
7643 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7644 "any other element [%" PRIu32 ") of pInfos.",
7645 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007646 break;
7647 }
7648 }
7649 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7650 if (pInfos[i].pGeometries) {
7651 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7652 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7653 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7654 skip |= LogError(
7655 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7656 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7657 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7658 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7659 }
7660 } else {
7661 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7662 skip |= LogError(
7663 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7664 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7665 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7666 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7667 }
7668 }
7669 }
7670 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7671 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7672 skip |= LogError(
7673 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7674 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7675 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7676 }
7677 }
7678 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7679 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7680 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7681 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7682 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7683 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7684 }
7685 }
7686 } else if (pInfos[i].ppGeometries) {
7687 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7688 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7689 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7690 skip |= LogError(
7691 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7692 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7693 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7694 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7695 }
7696 } else {
7697 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7698 skip |= LogError(
7699 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7700 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7701 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7702 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7703 }
7704 }
7705 }
7706 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7707 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7708 skip |= LogError(
7709 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7710 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7711 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7712 }
7713 }
7714 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7715 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7716 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7717 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7718 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7719 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7720 }
7721 }
7722 }
7723 }
7724 }
7725 return skip;
7726}
7727
7728bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7729 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7730 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7731 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7732 bool skip = false;
7733 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7734 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007735 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007736 if (!ray_tracing_acceleration_structure_features ||
7737 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7738 skip |=
7739 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7740 "vkBuildAccelerationStructuresKHR: The "
7741 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7742 }
7743 for (uint32_t i = 0; i < infoCount; ++i) {
7744 for (uint32_t j = 0; j < infoCount; ++j) {
7745 if (i == j) continue;
7746 bool found = false;
7747 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007748 skip |=
7749 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7750 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7751 ") of pInfos must "
7752 "not be "
7753 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7754 ") of pInfos.",
7755 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007756 found = true;
7757 }
7758 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007759 skip |=
7760 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7761 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7762 ") of pInfos must "
7763 "not be "
7764 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7765 ") of pInfos.",
7766 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007767 found = true;
7768 }
7769 if (found) break;
7770 }
7771 }
7772 return skip;
7773}
7774
7775bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7776 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7777 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7778 bool skip = false;
7779 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7780 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007781 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7782 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007783 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7784 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7785 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7786 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01007787 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
7788 }
7789 if (pBuildInfo != nullptr) {
7790 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
7791 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
7792 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
7793 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
7794 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007795 }
7796 return skip;
7797}
sfricke-samsungecafb192021-01-17 08:21:14 -08007798
7799bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7800 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7801 const VkAllocationCallbacks *pAllocator,
7802 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7803 bool skip = false;
7804 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7805 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7806 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7807 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7808 }
7809 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007810}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007811
7812bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7813 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7814 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7815 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7816 bool skip = false;
7817 const auto *vertex_input_dynamic_state_features =
7818 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7819 const auto *vertex_attribute_divisor_features =
7820 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7821
7822 // VUID-vkCmdSetVertexInputEXT-None-04790
7823 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7824 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7825 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7826 }
7827
7828 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7829 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7830 skip |=
7831 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7832 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7833 }
7834
7835 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7836 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7837 skip |= LogError(
7838 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7839 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7840 }
7841
7842 // VUID-vkCmdSetVertexInputEXT-binding-04793
7843 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7844 bool binding_found = false;
7845 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7846 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7847 binding_found = true;
7848 break;
7849 }
7850 }
7851 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007852 skip |= LogError(
7853 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7854 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007855 }
7856 }
7857
7858 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7859 if (vertexBindingDescriptionCount > 1) {
7860 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7861 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7862 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7863 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7864 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007865 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7866 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007867 }
7868 }
7869 }
7870 }
7871
7872 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7873 if (vertexAttributeDescriptionCount > 1) {
7874 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7875 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7876 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7877 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7878 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007879 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7880 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007881 }
7882 }
7883 }
7884 }
7885
7886 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7887 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7888 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007889 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7890 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7891 "].binding is greater than maxVertexInputBindings",
7892 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007893 }
7894
7895 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7896 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007897 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7898 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7899 "].stride is greater than maxVertexInputBindingStride",
7900 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007901 }
7902
7903 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7904 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7905 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7906 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007907 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7908 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007909 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7910 binding);
7911 }
7912
7913 if (pVertexBindingDescriptions[binding].divisor > 1) {
7914 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7915 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7916 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007917 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7918 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007919 "vertexAttributeInstanceRateDivisor is not enabled",
7920 binding);
7921 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007922 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007923 if (pVertexBindingDescriptions[binding].divisor >
7924 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007925 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
7926 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7927 "].divisor is greater than maxVertexAttribDivisor",
7928 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007929 }
7930
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007931 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007932 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007933 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
7934 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7935 "].divisor is greater than 1 but inputRate "
7936 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7937 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007938 }
7939 }
7940 }
7941 }
7942
7943 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007944 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007945 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007946 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
7947 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7948 "].location is greater than maxVertexInputAttributes",
7949 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007950 }
7951
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007952 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007953 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007954 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
7955 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7956 "].binding is greater than maxVertexInputBindings",
7957 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007958 }
7959
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007960 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007961 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007962 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
7963 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7964 "].offset is greater than maxVertexInputAttributeOffset",
7965 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007966 }
7967
7968 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7969 VkFormatProperties properties;
7970 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7971 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7972 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007973 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7974 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007975 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7976 attribute);
7977 }
7978 }
7979
7980 return skip;
7981}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007982
7983bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7984 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7985 const void *pValues) const {
7986 bool skip = false;
7987 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7988 // Check that offset + size don't exceed the max.
7989 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7990 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007991 skip |=
7992 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7993 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
7994 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007995 }
7996 if (size > max_push_constants_size - offset) {
7997 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007998 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
7999 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008000 offset, size, max_push_constants_size);
8001 }
8002
8003 // size needs to be non-zero and a multiple of 4.
8004 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008005 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8006 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008007 }
8008
8009 // offset needs to be a multiple of 4.
8010 if ((offset & 0x3) != 0) {
8011 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008012 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008013 }
8014 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008015}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008016
8017bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8018 uint32_t srcCacheCount,
8019 const VkPipelineCache *pSrcCaches) const {
8020 bool skip = false;
8021 if (pSrcCaches) {
8022 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8023 if (pSrcCaches[index0] == dstCache) {
8024 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8025 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8026 report_data->FormatHandle(dstCache).c_str());
8027 break;
8028 }
8029 }
8030 }
8031 return skip;
8032}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008033
8034bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8035 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8036 uint32_t rangeCount,
8037 const VkImageSubresourceRange *pRanges) const {
8038 bool skip = false;
8039 if (!pColor) {
8040 skip |=
8041 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8042 }
8043 return skip;
8044}
8045
8046bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8047 const VkRenderPassBeginInfo *const rp_begin) const {
8048 bool skip = false;
8049 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8050 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8051 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008052 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008053 func_name, rp_begin->clearValueCount);
8054 }
8055 return skip;
8056}
8057
8058bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8059 VkSubpassContents) const {
8060 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8061 return skip;
8062}
8063
8064bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8065 const VkRenderPassBeginInfo *pRenderPassBegin,
8066 const VkSubpassBeginInfo *) const {
8067 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8068 return skip;
8069}
8070
8071bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8072 const VkSubpassBeginInfo *) const {
8073 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8074 return skip;
8075}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008076
8077bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8078 uint32_t firstDiscardRectangle,
8079 uint32_t discardRectangleCount,
8080 const VkRect2D *pDiscardRectangles) const {
8081 bool skip = false;
8082
8083 if (pDiscardRectangles) {
8084 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8085 const int64_t x_sum =
8086 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8087 if (x_sum > std::numeric_limits<int32_t>::max()) {
8088 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8089 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8090 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8091 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8092 }
8093
8094 const int64_t y_sum =
8095 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8096 if (y_sum > std::numeric_limits<int32_t>::max()) {
8097 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8098 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8099 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8100 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8101 }
8102 }
8103 }
8104
8105 return skip;
8106}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008107
8108bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8109 uint32_t queryCount, size_t dataSize, void *pData,
8110 VkDeviceSize stride, VkQueryResultFlags flags) const {
8111 bool skip = false;
8112
8113 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8114 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8115 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8116 }
8117
8118 return skip;
8119}
ziga-lunargcf340c42021-08-19 00:13:38 +02008120
8121bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8122 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8123 bool skip = false;
8124
8125 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8126 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8127 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8128 ") is not a multiple of 4.",
8129 pConditionalRenderingBegin->offset);
8130 }
8131
8132 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008133}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008134
8135bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8136 VkSurfaceKHR surface,
8137 uint32_t *pSurfaceFormatCount,
8138 VkSurfaceFormatKHR *pSurfaceFormats) const {
8139 bool skip = false;
8140 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8141 skip |= LogError(
8142 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8143 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8144 }
8145 return skip;
8146}
8147
8148bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8149 VkSurfaceKHR surface,
8150 uint32_t *pPresentModeCount,
8151 VkPresentModeKHR *pPresentModes) const {
8152 bool skip = false;
8153 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8154 skip |= LogError(
8155 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8156 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8157 }
8158 return skip;
8159}
8160
8161bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8162 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8163 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8164 bool skip = false;
8165 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8166 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8167 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8168 "VK_GOOGLE_surfaceless_query is not enabled.");
8169 }
8170 return skip;
8171}
8172
8173bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8174 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8175 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8176 bool skip = false;
8177 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8178 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8179 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8180 "VK_GOOGLE_surfaceless_query is not enabled.");
8181 }
8182 return skip;
8183}
8184
8185#ifdef VK_USE_PLATFORM_WIN32_KHR
8186bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8187 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8188 VkPresentModeKHR *pPresentModes) const {
8189 bool skip = false;
8190 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8191 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8192 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8193 "VK_GOOGLE_surfaceless_query is not enabled.");
8194 }
8195 return skip;
8196}
8197#endif // VK_USE_PLATFORM_WIN32_KHR