blob: 44b755f1d8cade94d480265f585c195672953d70 [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(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003038 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06485",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003039 "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(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003065 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06486",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003066 "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(
Mike Schuchardt979898a2022-01-11 10:46:59 -08003120 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06484",
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003121 "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,
Mike Schuchardt979898a2022-01-11 10:46:59 -08004005 const bool isPushDescriptor) 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.
Mike Schuchardt979898a2022-01-11 10:46:59 -08004018 if (!isPushDescriptor) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004019 // 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)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004030 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004031 if (!isPushDescriptor) {
4032 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4033 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or
4034 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pImageInfo must be a pointer to an array of descriptorCount valid
4035 // VkDescriptorImageInfo structures. Valid imageView handles are checked in
4036 // ObjectLifetimes::ValidateDescriptorWrite.
4037 skip |= LogError(
4038 device, "VUID-vkUpdateDescriptorSets-pDescriptorWrites-06493",
4039 "%s(): if pDescriptorWrites[%" PRIu32
4040 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4041 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4042 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4043 vkCallingFunction, i, i);
4044 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4045 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4046 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4047 // If called from vkCmdPushDescriptorSetKHR, pImageInfo is only requred for descriptor types
4048 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, and
4049 // VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
4050 skip |= LogError(device, "VUID-vkCmdPushDescriptorSetKHR-pDescriptorWrites-06494",
4051 "%s(): if pDescriptorWrites[%" PRIu32
4052 "].descriptorType is VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE "
4053 "or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32
4054 "].pImageInfo must not be NULL.",
4055 vkCallingFunction, i, i);
4056 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004057 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4058 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004059 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4060 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004061 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4062 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004063 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004064 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4065 ParameterName::IndexVector{i, descriptor_index}),
4066 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004067 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004068 }
4069 }
4070 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4071 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4072 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4073 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4074 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4075 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4076 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004077 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004078 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004079 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004080 "%s(): if pDescriptorWrites[%" PRIu32
4081 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004082 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4083 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004084 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004085 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004086 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004087 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004088 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004089 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004090 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4091 ++descriptor_index) {
4092 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4093 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4094 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004095 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004096 "%s(): if pDescriptorWrites[%" PRIu32
4097 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004098 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004099 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4100 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004101 }
4102 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004103 }
4104 }
4105 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4106 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004107 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004108 }
4109
4110 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4111 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004112 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
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, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004116 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004117 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
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 minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004120 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004121 }
4122 }
4123 }
4124 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4125 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004126 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004127 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4128 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004129 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004130 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004131 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004132 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004133 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004134 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004135 }
4136 }
4137 }
4138 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004139 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4140 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004141 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004142 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004143 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4144 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4145 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4146 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004147 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004148 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4149 pDescriptorWrites[i].descriptorCount);
4150 }
4151 // further checks only if we have right structtype
4152 if (pnext_struct) {
4153 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4154 skip |= LogError(
4155 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004156 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4157 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004158 ".",
4159 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004160 }
sourav parmarbcee7512020-12-28 14:34:49 -08004161 if (pnext_struct->accelerationStructureCount == 0) {
4162 skip |= LogError(device,
4163 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004164 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004165 }
4166 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004167 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004168 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4169 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4170 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4171 skip |= LogError(device,
4172 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4173 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004174 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004175 }
4176 }
4177 }
sourav parmarbcee7512020-12-28 14:34:49 -08004178 }
4179 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004180 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004181 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4182 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4183 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4184 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004185 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004186 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4187 pDescriptorWrites[i].descriptorCount);
4188 }
4189 // further checks only if we have right structtype
4190 if (pnext_struct) {
4191 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4192 skip |= LogError(
4193 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004194 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4195 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004196 ".",
4197 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004198 }
sourav parmarbcee7512020-12-28 14:34:49 -08004199 if (pnext_struct->accelerationStructureCount == 0) {
4200 skip |= LogError(device,
4201 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004202 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004203 }
4204 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004205 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004206 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4207 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4208 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4209 skip |= LogError(device,
4210 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4211 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004212 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004213 }
4214 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004215 }
4216 }
4217 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004218 }
4219 }
4220 return skip;
4221}
4222
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004223bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4224 const VkWriteDescriptorSet *pDescriptorWrites,
4225 uint32_t descriptorCopyCount,
4226 const VkCopyDescriptorSet *pDescriptorCopies) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08004227 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites, false);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004228}
4229
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004230bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004231 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004232 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004233 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4234}
4235
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004236bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4237 const VkAllocationCallbacks *pAllocator,
4238 VkRenderPass *pRenderPass) const {
4239 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4240}
4241
Mike Schuchardt2df08912020-12-15 16:28:09 -08004242bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004243 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004244 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004245 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4246}
4247
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004248bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4249 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004250 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004251 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004252
4253 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4254 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4255 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004256 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4257 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004258 return skip;
4259}
4260
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004261bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004262 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004263 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004264
4265 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4266 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004267 bool cb_is_secondary;
4268 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004269 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004270 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4271 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004272
Tony-LunarG3c287f62020-12-17 12:39:49 -07004273 if (cb_is_secondary) {
4274 // Implicit VUs
4275 // validate only sType here; pointer has to be validated in core_validation
4276 const bool k_not_required = false;
4277 const char *k_no_vuid = nullptr;
4278 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4279 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004280 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4281 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004282
Tony-LunarG3c287f62020-12-17 12:39:49 -07004283 if (info) {
4284 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004285 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004286 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4287 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004288 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004289 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004290 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4291 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4292 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4293 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004294
Tony-LunarG3c287f62020-12-17 12:39:49 -07004295 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004296
Tony-LunarG3c287f62020-12-17 12:39:49 -07004297 // Explicit VUs
4298 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004299 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004300 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4301 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4302 cmd_name);
4303 }
4304
4305 if (physical_device_features.inheritedQueries) {
4306 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004307 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4308 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4309 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004310 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004311 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004312 }
4313
4314 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004315 skip |=
4316 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4317 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4318 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4319 } else { // !pipelineStatisticsQuery
4320 skip |=
4321 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4322 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004323 }
4324
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004325 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004326 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004327 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004328 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4329 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4330 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004331 commandBuffer,
4332 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004333 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4334 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4335 }
Petr Kraus139757b2019-08-15 17:19:33 +02004336 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004337
4338 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4339 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4340 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4341 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4342 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4343 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4344 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4345 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4346 }
Petr Kraus139757b2019-08-15 17:19:33 +02004347 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004348 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004349 return skip;
4350}
4351
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004352bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004353 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004354 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004355
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004356 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004357 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004358 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4359 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4360 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004361 }
4362 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004363 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4364 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4365 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004366 }
4367 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004368 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004369 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004370 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4371 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4372 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4373 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004374 }
4375 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004376
4377 if (pViewports) {
4378 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4379 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004380 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004381 skip |= manual_PreCallValidateViewport(
4382 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004383 }
4384 }
4385
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004386 return skip;
4387}
4388
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004389bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004390 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004391 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004392
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004393 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004394 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004395 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4396 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4397 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004398 }
4399 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004400 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4401 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4402 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004403 }
4404 } else { // multiViewport enabled
4405 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004406 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004407 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4408 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4409 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4410 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004411 }
4412 }
4413
Petr Kraus6260f0a2018-02-27 21:15:55 +01004414 if (pScissors) {
4415 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4416 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004417
Petr Kraus6260f0a2018-02-27 21:15:55 +01004418 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004419 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4420 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4421 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004422 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004423
Petr Kraus6260f0a2018-02-27 21:15:55 +01004424 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004425 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4426 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4427 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004428 }
4429
4430 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4431 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004432 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4433 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4434 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4435 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004436 }
4437
4438 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4439 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004440 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4441 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4442 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4443 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004444 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004445 }
4446 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004447
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004448 return skip;
4449}
4450
Jeff Bolz5c801d12019-10-09 10:38:45 -05004451bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004452 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004453
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004454 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004455 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4456 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004457 }
4458
4459 return skip;
4460}
4461
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004462bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004463 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004464 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004465
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004466 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004467 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004468 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4469 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004470 }
4471 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004472 skip |=
4473 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4474 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4475 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004476 }
4477 return skip;
4478}
4479
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004480bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004481 VkDeviceSize offset, uint32_t drawCount,
4482 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004483 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004484 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004485 skip |=
4486 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4487 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4488 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004489 }
4490 if (drawCount > device_limits.maxDrawIndirectCount) {
4491 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004492 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4493 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004494 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004495 }
4496 return skip;
4497}
4498
sfricke-samsungf692b972020-05-02 08:00:45 -07004499bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4500 VkDeviceSize countBufferOffset, bool khr) const {
4501 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004502 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004503 if (offset & 3) {
4504 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004505 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004506 }
4507
4508 if (countBufferOffset & 3) {
4509 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004510 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004511 countBufferOffset);
4512 }
4513 return skip;
4514}
4515
4516bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4517 VkDeviceSize offset, VkBuffer countBuffer,
4518 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4519 uint32_t stride) const {
4520 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4521}
4522
4523bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4524 VkDeviceSize offset, VkBuffer countBuffer,
4525 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4526 uint32_t stride) const {
4527 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4528}
4529
4530bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4531 VkDeviceSize countBufferOffset, bool khr) const {
4532 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004533 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004534 if (offset & 3) {
4535 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004536 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004537 }
4538
4539 if (countBufferOffset & 3) {
4540 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004541 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004542 countBufferOffset);
4543 }
4544 return skip;
4545}
4546
4547bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4548 VkDeviceSize offset, VkBuffer countBuffer,
4549 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4550 uint32_t stride) const {
4551 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4552}
4553
4554bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4555 VkDeviceSize offset, VkBuffer countBuffer,
4556 VkDeviceSize countBufferOffset,
4557 uint32_t maxDrawCount, uint32_t stride) const {
4558 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4559}
4560
Tony-LunarG4490de42021-06-21 15:49:19 -06004561bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4562 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4563 uint32_t firstInstance, uint32_t stride) const {
4564 bool skip = false;
4565 if (stride & 3) {
4566 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4567 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4568 }
4569 if (drawCount && nullptr == pVertexInfo) {
4570 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4571 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4572 "one or more valid instances of VkMultiDrawInfoEXT structures");
4573 }
4574 return skip;
4575}
4576
4577bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4578 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4579 uint32_t instanceCount, uint32_t firstInstance,
4580 uint32_t stride, const int32_t *pVertexOffset) const {
4581 bool skip = false;
4582 if (stride & 3) {
4583 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4584 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4585 }
4586 if (drawCount && nullptr == pIndexInfo) {
4587 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4588 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4589 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4590 }
4591 return skip;
4592}
4593
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004594bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4595 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004596 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004597 bool skip = false;
4598 for (uint32_t rect = 0; rect < rectCount; rect++) {
4599 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004600 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004601 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004602 }
sfricke-samsung10867682020-04-25 02:20:39 -07004603 if (pRects[rect].rect.extent.width == 0) {
4604 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004605 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004606 }
4607 if (pRects[rect].rect.extent.height == 0) {
4608 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004609 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004610 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004611 }
4612 return skip;
4613}
4614
Andrew Fobel3abeb992020-01-20 16:33:22 -05004615bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4616 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4617 VkImageFormatProperties2 *pImageFormatProperties,
4618 const char *apiName) const {
4619 bool skip = false;
4620
4621 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004622 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004623 if (image_stencil_struct != nullptr) {
4624 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4625 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4626 // No flags other than the legal attachment bits may be set
4627 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4628 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004629 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4630 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4631 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4632 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4633 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004634 }
4635 }
4636 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004637 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4638 if (image_drm_format) {
4639 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4640 skip |= LogError(
4641 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4642 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4643 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4644 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4645 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004646 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4647 skip |= LogError(
4648 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4649 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4650 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4651 apiName, image_drm_format->queueFamilyIndexCount);
4652 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004653 } else {
4654 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4655 skip |= LogError(
4656 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4657 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4658 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4659 apiName);
4660 }
4661 }
4662 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4663 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4664 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4665 if (!format_list || format_list->viewFormatCount == 0) {
4666 skip |= LogError(
4667 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4668 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4669 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4670 apiName);
4671 }
4672 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004673 }
4674
4675 return skip;
4676}
4677
4678bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4679 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4680 VkImageFormatProperties2 *pImageFormatProperties) const {
4681 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4682 "vkGetPhysicalDeviceImageFormatProperties2");
4683}
4684
4685bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4686 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4687 VkImageFormatProperties2 *pImageFormatProperties) const {
4688 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4689 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4690}
4691
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004692bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4693 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4694 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4695 bool skip = false;
4696
4697 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4698 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4699 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4700 }
4701
4702 return skip;
4703}
4704
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004705bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4706 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4707 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4708 bool skip = false;
4709
4710 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4711 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4712 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4713 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4714 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4715 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4716 }
4717
ziga-lunarg42f884b2021-08-25 16:13:20 +02004718 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004719}
4720
sfricke-samsung3999ef62020-02-09 17:05:59 -08004721bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4722 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4723 bool skip = false;
4724
4725 if (pRegions != nullptr) {
4726 for (uint32_t i = 0; i < regionCount; i++) {
4727 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004728 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004729 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004730 }
4731 }
4732 }
4733 return skip;
4734}
4735
Jeff Leger178b1e52020-10-05 12:22:23 -04004736bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4737 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4738 bool skip = false;
4739
4740 if (pCopyBufferInfo->pRegions != nullptr) {
4741 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4742 if (pCopyBufferInfo->pRegions[i].size == 0) {
4743 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004744 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004745 }
4746 }
4747 }
4748 return skip;
4749}
4750
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004751bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004752 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4753 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004754 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004755
4756 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004757 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4758 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4759 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004760 }
4761
4762 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004763 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4764 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4765 "), must be greater than zero and less than or equal to 65536.",
4766 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004767 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004768 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4769 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4770 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004771 }
4772 return skip;
4773}
4774
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004775bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004776 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004777 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004778
4779 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004780 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4781 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4782 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004783 }
4784
4785 if (size != VK_WHOLE_SIZE) {
4786 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004787 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004788 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4789 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004790 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004791 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4792 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004793 }
4794 }
4795 return skip;
4796}
4797
sfricke-samsunga1d00272021-03-10 21:37:41 -08004798bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004799 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004800
4801 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004802 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4803 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4804 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4805 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004806 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004807 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4808 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4809 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004810 }
4811
4812 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4813 // queueFamilyIndexCount uint32_t values
4814 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004815 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004816 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004817 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004818 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4819 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004820 }
4821 }
4822
Dave Houlton413a6782018-05-22 13:01:54 -06004823 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004824 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004825
sfricke-samsunga1d00272021-03-10 21:37:41 -08004826 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4827 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4828 if (format_list_info) {
4829 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4830 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4831 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4832 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004833 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4834 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004835 func_name, viewFormatCount);
4836 }
4837
4838 // Using the first format, compare the rest of the formats against it that they are compatible
4839 for (uint32_t i = 1; i < viewFormatCount; i++) {
4840 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4841 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4842 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4843 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004844 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4845 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004846 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4847 string_VkFormat(format_list_info->pViewFormats[i]));
4848 }
4849 }
4850 }
4851
4852 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4853 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4854 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4855 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4856 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4857 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4858 func_name);
4859 } else {
4860 if (format_list_info == nullptr) {
4861 skip |= LogError(
4862 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4863 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4864 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4865 func_name);
4866 } else if (format_list_info->viewFormatCount == 0) {
4867 skip |= LogError(
4868 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4869 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4870 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4871 func_name);
4872 } else {
4873 bool found_base_format = false;
4874 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4875 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4876 found_base_format = true;
4877 break;
4878 }
4879 }
4880 if (!found_base_format) {
4881 skip |=
4882 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4883 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4884 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4885 "pCreateInfo->imageFormat.",
4886 func_name);
4887 }
4888 }
4889 }
4890 }
4891 }
4892 return skip;
4893}
4894
4895bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4896 const VkAllocationCallbacks *pAllocator,
4897 VkSwapchainKHR *pSwapchain) const {
4898 bool skip = false;
4899 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4900 return skip;
4901}
4902
4903bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4904 const VkSwapchainCreateInfoKHR *pCreateInfos,
4905 const VkAllocationCallbacks *pAllocator,
4906 VkSwapchainKHR *pSwapchains) const {
4907 bool skip = false;
4908 if (pCreateInfos) {
4909 for (uint32_t i = 0; i < swapchainCount; i++) {
4910 std::stringstream func_name;
4911 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4912 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4913 }
4914 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004915 return skip;
4916}
4917
Jeff Bolz5c801d12019-10-09 10:38:45 -05004918bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004919 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004920
4921 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004922 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004923 if (present_regions) {
4924 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004925 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004926 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4927 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004928 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004929 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4930 "extension swapchainCount is %i. These values must be equal.",
4931 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004932 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004933 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004934 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4935 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004936 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4937 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4938 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004939 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004940 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004941 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004942 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004943 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004944 }
4945 }
4946
4947 return skip;
4948}
4949
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004950bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4951 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4952 const VkAllocationCallbacks *pAllocator,
4953 VkDisplayModeKHR *pMode) const {
4954 bool skip = false;
4955
4956 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4957 if (display_mode_parameters.visibleRegion.width == 0) {
4958 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4959 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4960 }
4961 if (display_mode_parameters.visibleRegion.height == 0) {
4962 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4963 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4964 }
4965 if (display_mode_parameters.refreshRate == 0) {
4966 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4967 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4968 }
4969
4970 return skip;
4971}
4972
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004973#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004974bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4975 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4976 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004977 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004978 bool skip = false;
4979
4980 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004981 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4982 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004983 }
4984
4985 return skip;
4986}
4987#endif // VK_USE_PLATFORM_WIN32_KHR
4988
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004989static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
4990 bool partial_overlap = false;
4991
4992 static const std::vector<VkDescriptorType> all_descriptor_types = {
4993 VK_DESCRIPTOR_TYPE_SAMPLER,
4994 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4995 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4996 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4997 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4998 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4999 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
5000 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
5001 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
5002 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
5003 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
5004 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
5005 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
5006 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
5007 };
5008
5009 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
5010 if (mutable_descriptor_type) {
5011 std::vector<VkDescriptorType> first_types, second_types;
5012 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
5013 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
5014 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
5015 }
5016 } else {
5017 first_types = all_descriptor_types;
5018 }
5019 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
5020 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
5021 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5022 }
5023 } else {
5024 second_types = all_descriptor_types;
5025 }
5026
5027 bool complete_overlap = first_types.size() == second_types.size();
5028 bool disjoint = true;
5029 for (const auto first_type : first_types) {
5030 bool found = false;
5031 for (const auto second_type : second_types) {
5032 if (first_type == second_type) {
5033 found = true;
5034 break;
5035 }
5036 }
5037 if (found) {
5038 disjoint = false;
5039 } else {
5040 complete_overlap = false;
5041 }
5042 if (!disjoint && !complete_overlap) {
5043 partial_overlap = true;
5044 break;
5045 }
5046 }
5047 }
5048
5049 return partial_overlap;
5050}
5051
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005052bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005053 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005054 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005055 bool skip = false;
5056
5057 if (pCreateInfo) {
5058 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005059 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5060 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005061 }
5062
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005063 const auto *mutable_descriptor_type_features =
5064 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5065 bool mutable_descriptor_type_enabled =
5066 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5067
Petr Krausc8655be2017-09-27 18:56:51 +02005068 if (pCreateInfo->pPoolSizes) {
5069 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5070 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005071 skip |= LogError(
5072 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005073 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005074 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005075 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5076 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005077 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5078 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5079 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5080 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5081 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005082 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005083 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5084 skip |=
5085 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5086 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5087 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5088 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5089 i);
5090 }
5091 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5092 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5093 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5094 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5095 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5096 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5097 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5098 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5099 " and have sets which partially overlap.",
5100 i, j);
5101 }
5102 }
5103 }
5104 }
Petr Krausc8655be2017-09-27 18:56:51 +02005105 }
5106 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005107
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005108 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5109 skip |=
5110 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5111 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5112 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5113 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005114 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5115 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5116 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5117 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5118 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5119 }
Petr Krausc8655be2017-09-27 18:56:51 +02005120 }
5121
5122 return skip;
5123}
5124
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005125bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005126 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005127 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005128
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005129 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005130 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005131 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5132 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5133 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005134 }
5135
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005136 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005137 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005138 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5139 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5140 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005141 }
5142
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005143 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005144 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005145 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5146 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5147 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005148 }
5149
5150 return skip;
5151}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005153bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005154 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005155 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005156
5157 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005158 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5159 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005160 }
5161 return skip;
5162}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005163
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005164bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5165 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005166 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005167 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005168
5169 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005170 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005171 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005172 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5173 "vkCmdDispatch(): baseGroupX (%" PRIu32
5174 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5175 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005176 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005177 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5178 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5179 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5180 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005181 }
5182
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005183 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005184 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005185 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5186 "vkCmdDispatch(): baseGroupY (%" PRIu32
5187 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5188 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005189 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005190 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5191 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5192 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5193 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005194 }
5195
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005196 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005197 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005198 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5199 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5200 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5201 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005202 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005203 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5204 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5205 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5206 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005207 }
5208
5209 return skip;
5210}
5211
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005212bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5213 VkPipelineBindPoint pipelineBindPoint,
5214 VkPipelineLayout layout, uint32_t set,
5215 uint32_t descriptorWriteCount,
5216 const VkWriteDescriptorSet *pDescriptorWrites) const {
Mike Schuchardt979898a2022-01-11 10:46:59 -08005217 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, true);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005218}
5219
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005220bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5221 uint32_t firstExclusiveScissor,
5222 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005223 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005224 bool skip = false;
5225
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005226 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005227 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005228 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005229 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5230 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5231 ") is not 0.",
5232 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005233 }
5234 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005235 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005236 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5237 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5238 ") is not 1.",
5239 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005240 }
5241 } else { // multiViewport enabled
5242 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005243 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005244 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5245 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5246 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5247 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005248 }
5249 }
5250
Jeff Bolz3e71f782018-08-29 23:15:45 -05005251 if (pExclusiveScissors) {
5252 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5253 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5254
5255 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005256 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5257 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5258 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005259 }
5260
5261 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005262 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5263 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5264 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005265 }
5266
5267 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5268 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005269 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5270 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5271 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5272 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005273 }
5274
5275 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5276 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005277 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5278 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5279 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5280 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005281 }
5282 }
5283 }
5284
5285 return skip;
5286}
5287
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005288bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5289 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005290 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005291 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005292 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5293 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5294 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5295 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5296 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5297 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005298 }
5299
5300 return skip;
5301}
5302
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005303bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5304 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005305 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005306 bool skip = false;
5307
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005308 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005309 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005310 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005311 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5312 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5313 ") is not 0.",
5314 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005315 }
5316 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005317 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005318 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5319 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5320 ") is not 1.",
5321 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005322 }
5323 }
5324
Jeff Bolz9af91c52018-09-01 21:53:57 -05005325 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005326 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005327 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5328 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5329 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5330 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005331 }
5332
5333 return skip;
5334}
5335
Jeff Bolz5c801d12019-10-09 10:38:45 -05005336bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5337 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5338 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005339 bool skip = false;
5340
Dave Houlton142c4cb2018-10-17 15:04:41 -06005341 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005342 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5343 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5344 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005345 }
5346
5347 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005348 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005349 }
5350
5351 return skip;
5352}
5353
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005354bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005355 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005356 bool skip = false;
5357
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005358 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005359 skip |= LogError(
5360 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005361 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5362 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005363 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005364 }
5365
5366 return skip;
5367}
5368
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005369bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5370 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005371 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005372 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005373 static const int condition_multiples = 0b0011;
5374 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005375 skip |= LogError(
5376 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005377 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005378 }
Lockee1c22882019-06-10 16:02:54 -06005379 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005380 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5381 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5382 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5383 stride);
Lockee1c22882019-06-10 16:02:54 -06005384 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005385 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005386 skip |= LogError(
5387 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005388 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5389 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005390 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005391 if (drawCount > device_limits.maxDrawIndirectCount) {
5392 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005393 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5394 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005395 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005396 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005397 return skip;
5398}
5399
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005400bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5401 VkDeviceSize offset, VkBuffer countBuffer,
5402 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005403 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005404 bool skip = false;
5405
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005406 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005407 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5408 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5409 "), is not a multiple of 4.",
5410 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005411 }
5412
5413 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005414 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5415 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5416 "), is not a multiple of 4.",
5417 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005418 }
5419
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005420 return skip;
5421}
5422
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005423bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005424 const VkAllocationCallbacks *pAllocator,
5425 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005426 bool skip = false;
5427
5428 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5429 if (pCreateInfo != nullptr) {
5430 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5431 // VkQueryPipelineStatisticFlagBits values
5432 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5433 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005434 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5435 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5436 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5437 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005438 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005439 if (pCreateInfo->queryCount == 0) {
5440 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5441 "vkCreateQueryPool(): queryCount must be greater than zero.");
5442 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005443 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005444 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005445}
5446
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005447bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5448 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005449 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005450 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5451 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005452}
5453
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005454void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005455 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5456 VkResult result) {
5457 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005458 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005459}
5460
Mike Schuchardt2df08912020-12-15 16:28:09 -08005461void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005462 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5463 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005464 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005465 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005466 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005467}
5468
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005469void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5470 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005471 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005472 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005473 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005474}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005475
Tony-LunarG3c287f62020-12-17 12:39:49 -07005476void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005477 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005478 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005479 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005480 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005481 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005482 }
5483 }
5484}
5485
5486void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005487 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005488 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005489 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5490 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5491 }
5492}
5493
5494void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005495 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005496 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005497 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5498 if (item->second == commandPool) {
5499 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005500 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005501 ++item;
5502 }
5503 }
5504}
5505
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005506bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005507 const VkAllocationCallbacks *pAllocator,
5508 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005509 bool skip = false;
5510
5511 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005512 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005513 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005514 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5515 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005516 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005517
5518 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005519 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005520 if (flags_info) {
5521 flags = flags_info->flags;
5522 }
5523
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005524 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005525 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005526 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005527 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5528 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005529 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005530 }
5531
5532#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005533 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005534#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005535 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5536 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005537#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005538 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005539#endif
5540
5541 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005542 skip |= LogError(
5543 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005544 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5545 }
5546 if (
5547#ifdef VK_USE_PLATFORM_WIN32_KHR
5548 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5549#endif
5550 (import_memory_fd && import_memory_fd->handleType) ||
5551#ifdef VK_USE_PLATFORM_ANDROID_KHR
5552 (import_memory_ahb && import_memory_ahb->buffer) ||
5553#endif
5554 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005555 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5556 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005557 }
5558 }
5559
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005560 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5561 if (export_memory) {
5562 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5563 if (export_memory_nv) {
5564 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5565 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5566 "VkExportMemoryAllocateInfoNV");
5567 }
5568#ifdef VK_USE_PLATFORM_WIN32_KHR
5569 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5570 if (export_memory_win32_nv) {
5571 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5572 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5573 "VkExportMemoryWin32HandleInfoNV");
5574 }
5575#endif
5576 }
5577
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005578 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005579 VkBool32 capture_replay = false;
5580 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005581 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005582 if (vulkan_12_features) {
5583 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5584 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5585 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005586 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005587 if (bda_features) {
5588 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5589 buffer_device_address = bda_features->bufferDeviceAddress;
5590 }
5591 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005592 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005593 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005594 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005595 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005596 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005597 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005598 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005599 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005600 }
5601 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005602 }
5603 return skip;
5604}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005605
Jason Macnak192fa0e2019-07-26 15:07:16 -07005606bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005607 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005608 bool skip = false;
5609
5610 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5611 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5612 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005613 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005614 } else {
5615 uint32_t vertex_component_size = 0;
5616 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5617 vertex_component_size = 4;
5618 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5619 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5620 vertex_component_size = 2;
5621 }
5622 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005623 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005624 }
5625 }
5626
5627 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5628 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005629 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005630 } else {
5631 uint32_t index_element_size = 0;
5632 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5633 index_element_size = 4;
5634 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5635 index_element_size = 2;
5636 }
5637 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005638 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005639 }
5640 }
5641 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5642 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005643 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005644 }
5645 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005646 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005647 }
5648 }
5649
5650 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005651 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%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::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5658 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005659 bool skip = false;
5660
5661 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005662 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005663 }
5664 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005665 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005666 }
5667
5668 return skip;
5669}
5670
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005671bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5672 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005673 bool skip = false;
5674 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005675 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005676 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005677 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005678 }
5679 return skip;
5680}
5681
5682bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005683 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005684 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005685 bool skip = false;
5686 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005687 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5688 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5689 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005690 }
5691 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005692 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5693 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5694 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005695 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005696 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5697 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5698 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5699 }
Jason Macnak5c954952019-07-09 15:46:12 -07005700 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5701 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005702 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5703 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5704 "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 -07005705 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005706 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005707 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005708 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5709 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005710 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5711 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005712 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005713 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005714 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5715 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5716 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005717 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005718 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005719 uint64_t total_triangle_count = 0;
5720 for (uint32_t i = 0; i < info.geometryCount; i++) {
5721 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005722
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005723 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005724
Jason Macnak5c954952019-07-09 15:46:12 -07005725 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5726 continue;
5727 }
5728 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5729 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005730 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005731 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5732 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5733 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005734 }
5735 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005736 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5737 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5738 for (uint32_t i = 1; i < info.geometryCount; i++) {
5739 const VkGeometryNV &geometry = info.pGeometries[i];
5740 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005741 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005742 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5743 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005744 "info.pGeometries[0].geometryType.",
5745 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005746 }
5747 }
5748 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005749 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5750 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5751 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5752 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5753 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5754 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5755 }
5756 }
5757 skip |=
5758 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005759 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005760 return skip;
5761}
5762
Ricardo Garciaa4935972019-02-21 17:43:18 +01005763bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5764 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005765 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005766 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005767 if (pCreateInfo) {
5768 if ((pCreateInfo->compactedSize != 0) &&
5769 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005770 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5771 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5772 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5773 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005774 }
Jason Macnak5c954952019-07-09 15:46:12 -07005775
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005776 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005777 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005778 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005779 return skip;
5780}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005781
Jeff Bolz5c801d12019-10-09 10:38:45 -05005782bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5783 const VkAccelerationStructureInfoNV *pInfo,
5784 VkBuffer instanceData, VkDeviceSize instanceOffset,
5785 VkBool32 update, VkAccelerationStructureNV dst,
5786 VkAccelerationStructureNV src, VkBuffer scratch,
5787 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005788 bool skip = false;
5789
5790 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005791 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005792 }
5793
5794 return skip;
5795}
5796
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005797bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5798 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5799 VkAccelerationStructureKHR *pAccelerationStructure) const {
5800 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005801 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005802 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005803 if (!acceleration_structure_features ||
5804 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5805 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5806 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5807 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005808 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005809 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5810 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005811 (acceleration_structure_features &&
5812 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005813 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005814 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5815 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5816 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5817 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005818 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005819 if (pCreateInfo->deviceAddress &&
5820 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5821 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5822 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5823 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5824 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005825 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5826 (acceleration_structure_features &&
5827 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5828 skip |= LogError(
5829 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5830 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5831 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5832 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005833 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5834 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005835 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5836 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005837 }
sourav parmar83c31b12020-05-06 12:30:54 -07005838 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005839 return skip;
5840}
5841
Jason Macnak5c954952019-07-09 15:46:12 -07005842bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5843 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005844 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005845 bool skip = false;
5846 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005847 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5848 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005849 }
5850 return skip;
5851}
5852
sourav parmarcd5fb182020-07-17 12:58:44 -07005853bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5854 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5855 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5856 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005857 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005858 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005859 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005860 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005861 }
5862 return skip;
5863}
5864
Peter Chen85366392019-05-14 15:20:11 -04005865bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5866 uint32_t createInfoCount,
5867 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5868 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005869 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005870 bool skip = false;
5871
5872 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005873 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5874 std::stringstream msg;
5875 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5876 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5877 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005878 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005879 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005880 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005881 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5882 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5883 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5884 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005885 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005886
5887 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005888 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005889 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5890 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5891 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5892 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5893 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5894 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5895 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5896 }
5897 }
5898
sourav parmarf4a78252020-04-10 13:04:21 -07005899 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5900 skip |=
5901 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5902 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5903 }
5904 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5905 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5906 skip |=
5907 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5908 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5909 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5910 }
5911 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5912 if (pCreateInfos[i].basePipelineIndex != -1) {
5913 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5914 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5915 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5916 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5917 "and pCreateInfos->basePipelineIndex is not -1.");
5918 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005919 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005920 skip |=
5921 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5922 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5923 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5924 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5925 "that element.");
5926 }
sourav parmarf4a78252020-04-10 13:04:21 -07005927 }
5928 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005929 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005930 skip |=
5931 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5932 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5933 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5934 "commands pCreateInfos parameter.");
5935 }
5936 } else {
5937 if (pCreateInfos[i].basePipelineIndex != -1) {
5938 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5939 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5940 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5941 }
5942 }
5943 }
5944 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5945 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5946 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5947 }
5948 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5949 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5950 "vkCreateRayTracingPipelinesNV: flags must not include "
5951 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5952 }
5953 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5954 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5955 "vkCreateRayTracingPipelinesNV: flags must not include "
5956 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5957 }
5958 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5959 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5960 "vkCreateRayTracingPipelinesNV: flags must not include "
5961 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5962 }
5963 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5964 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5965 "vkCreateRayTracingPipelinesNV: flags must not include "
5966 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5967 }
5968 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5969 skip |= LogError(
5970 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5971 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5972 }
5973 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5974 skip |= LogError(
5975 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5976 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5977 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005978 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5979 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5980 "vkCreateRayTracingPipelinesNV: flags must not include "
5981 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5982 }
5983 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5984 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5985 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5986 }
ziga-lunargdfffee42021-10-10 11:49:59 +02005987 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
5988 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
5989 "vkCreateRayTracingPipelinesNV: flags must not contain the "
5990 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
5991 }
Peter Chen85366392019-05-14 15:20:11 -04005992 }
5993
5994 return skip;
5995}
5996
sourav parmarcd5fb182020-07-17 12:58:44 -07005997bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5998 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5999 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006000 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006001 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006002 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
6003 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
6004 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006005 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006006 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02006007 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
6008 std::stringstream msg;
6009 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
6010 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
6011 &pCreateInfos[i].pStages[i]);
6012 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006013 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
6014 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
6015 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
6016 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6017 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
6018 }
6019 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
6020 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
6021 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6022 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6023 }
6024 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006025 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006026 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
6027 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07006028 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6029 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6030 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006031 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6032 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6033 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006034 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006035 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006036 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6037 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6038 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6039 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006040 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006041 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6042 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6043 }
6044 }
sourav parmarf4a78252020-04-10 13:04:21 -07006045 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006046 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6047 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006048 }
6049 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006050 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006051 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006052 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6053 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006054 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006055 }
6056 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6057 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6058 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006059 }
6060 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6061 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6062 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6063 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6064 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6065 skip |= LogError(
6066 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006067 "vkCreateRayTracingPipelinesKHR: If flags includes "
6068 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006069 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6070 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6071 "must not be VK_SHADER_UNUSED_KHR");
6072 }
6073 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6074 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6075 skip |= LogError(
6076 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006077 "vkCreateRayTracingPipelinesKHR: If flags includes "
6078 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006079 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6080 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6081 "element must not be VK_SHADER_UNUSED_KHR");
6082 }
6083 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006084 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6085 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6086 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6087 skip |= LogError(
6088 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6089 "vkCreateRayTracingPipelinesKHR: If "
6090 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6091 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6092 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6093 }
6094 }
sourav parmarf4a78252020-04-10 13:04:21 -07006095 }
6096 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6097 if (pCreateInfos[i].basePipelineIndex != -1) {
6098 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6099 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006100 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006101 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6102 "and pCreateInfos->basePipelineIndex is not -1.");
6103 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006104 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006105 skip |=
6106 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6107 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6108 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6109 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6110 "element.");
6111 }
sourav parmarf4a78252020-04-10 13:04:21 -07006112 }
6113 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006114 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006115 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006116 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006117 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6118 ") must be a valid into the calling"
6119 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006120 pCreateInfos[i].basePipelineIndex, createInfoCount);
6121 }
6122 } else {
6123 if (pCreateInfos[i].basePipelineIndex != -1) {
6124 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006125 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006126 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6127 }
6128 }
6129 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006130 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6131 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6132 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6133 "vkCreateRayTracingPipelinesKHR: If flags includes "
6134 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6135 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006136 }
6137 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6138 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6139 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6140 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6141 "pLibraryInfo and pLibraryInterface must be NULL.");
6142 }
6143 if (pCreateInfos[i].pLibraryInfo) {
6144 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6145 if (pCreateInfos[i].stageCount == 0) {
6146 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6147 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6148 "stageCount must not be 0.");
6149 }
6150 if (pCreateInfos[i].groupCount == 0) {
6151 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6152 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6153 "groupCount must not be 0.");
6154 }
6155 } else {
6156 if (pCreateInfos[i].pLibraryInterface == NULL) {
6157 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6158 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6159 "is greater than 0, its "
6160 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006161 }
6162 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006163 }
6164 if (pCreateInfos[i].pLibraryInterface) {
6165 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6166 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6167 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6168 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6169 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6170 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006171 }
6172 if (deferredOperation != VK_NULL_HANDLE) {
6173 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6174 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6175 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6176 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006177 }
6178 }
ziga-lunargdea76582021-09-17 14:38:08 +02006179 if (pCreateInfos[i].pDynamicState) {
6180 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6181 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6182 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6183 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6184 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6185 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6186 }
6187 }
6188 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006189 }
6190
6191 return skip;
6192}
6193
Mike Schuchardt21638df2019-03-16 10:52:02 -07006194#ifdef VK_USE_PLATFORM_WIN32_KHR
6195bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6196 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006197 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006198 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006199 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006200 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006201 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006202 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006203 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006204 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006205 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006206 skip |=
6207 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006208 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006209 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6210 skip |= validate_struct_type(
6211 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6212 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6213 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6214 if (pSurfaceInfo != NULL) {
6215 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6216 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6217 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6218
6219 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6220 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6221 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6222 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006223 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6224 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006225
Mike Schuchardt05b028d2022-01-05 14:15:00 -08006226 if (pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
6227 skip |= LogError(device, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
6228 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
6229 "VK_GOOGLE_surfaceless_query is not enabled.");
6230 }
6231
Mike Schuchardt21638df2019-03-16 10:52:02 -07006232 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6233 }
6234 return skip;
6235}
6236#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006237
6238bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6239 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006240 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006241 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6242 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006243 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006244 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6245 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6246 }
6247 return skip;
6248}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006249
6250bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006251 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006252 bool skip = false;
6253
6254 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006255 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006256 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006257 }
6258
6259 return skip;
6260}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006261
6262bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006263 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006264 bool skip = false;
6265
6266 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006267 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6268 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006269 }
6270
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006271 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006272 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006273 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6274 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006275 }
6276
6277 return skip;
6278}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006279
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006280bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6281 uint32_t bindingCount, const VkBuffer *pBuffers,
6282 const VkDeviceSize *pOffsets) const {
6283 bool skip = false;
6284 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006285 skip |=
6286 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6287 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6288 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006289 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6290 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006291 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6292 ") must be less than "
6293 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006294 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6295 }
6296
Jeff Bolz165818a2020-05-08 11:19:03 -05006297 for (uint32_t i = 0; i < bindingCount; ++i) {
6298 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006299 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006300 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006301 skip |=
6302 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6303 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006304 } else {
6305 if (pOffsets[i] != 0) {
6306 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006307 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6308 "] is not 0",
6309 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006310 }
6311 }
6312 }
6313 }
6314
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006315 return skip;
6316}
6317
Mark Lobodzinski84988402019-09-11 15:27:30 -06006318bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006319 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006320 bool skip = false;
6321 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006322 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6323 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006324 }
6325 return skip;
6326}
6327
6328bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006329 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006330 bool skip = false;
6331 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006332 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6333 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006334 }
6335 return skip;
6336}
Petr Kraus3d720392019-11-13 02:52:39 +01006337
6338bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6339 VkSemaphore semaphore, VkFence fence,
6340 uint32_t *pImageIndex) const {
6341 bool skip = false;
6342
6343 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006344 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6345 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006346 }
6347
6348 return skip;
6349}
6350
6351bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6352 uint32_t *pImageIndex) const {
6353 bool skip = false;
6354
6355 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006356 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6357 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006358 }
6359
6360 return skip;
6361}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006362
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006363bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6364 uint32_t firstBinding, uint32_t bindingCount,
6365 const VkBuffer *pBuffers,
6366 const VkDeviceSize *pOffsets,
6367 const VkDeviceSize *pSizes) const {
6368 bool skip = false;
6369
6370 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6371 for (uint32_t i = 0; i < bindingCount; ++i) {
6372 if (pOffsets[i] & 3) {
6373 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6374 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6375 }
6376 }
6377
6378 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6379 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6380 "%s: The firstBinding(%" PRIu32
6381 ") index is greater than or equal to "
6382 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6383 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6384 }
6385
6386 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6387 skip |=
6388 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6389 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6390 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6391 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6392 }
6393
6394 for (uint32_t i = 0; i < bindingCount; ++i) {
6395 // pSizes is optional and may be nullptr.
6396 if (pSizes != nullptr) {
6397 if (pSizes[i] != VK_WHOLE_SIZE &&
6398 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6399 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6400 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6401 ") is not VK_WHOLE_SIZE and is greater than "
6402 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6403 cmd_name, i, pSizes[i]);
6404 }
6405 }
6406 }
6407
6408 return skip;
6409}
6410
6411bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6412 uint32_t firstCounterBuffer,
6413 uint32_t counterBufferCount,
6414 const VkBuffer *pCounterBuffers,
6415 const VkDeviceSize *pCounterBufferOffsets) const {
6416 bool skip = false;
6417
6418 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6419 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6420 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6421 "%s: The firstCounterBuffer(%" PRIu32
6422 ") index is greater than or equal to "
6423 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6424 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6425 }
6426
6427 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6428 skip |=
6429 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6430 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6431 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6432 cmd_name, firstCounterBuffer, counterBufferCount,
6433 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6434 }
6435
6436 return skip;
6437}
6438
6439bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6440 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6441 const VkBuffer *pCounterBuffers,
6442 const VkDeviceSize *pCounterBufferOffsets) const {
6443 bool skip = false;
6444
6445 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6446 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6447 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6448 "%s: The firstCounterBuffer(%" PRIu32
6449 ") index is greater than or equal to "
6450 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6451 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6452 }
6453
6454 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6455 skip |=
6456 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6457 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6458 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6459 cmd_name, firstCounterBuffer, counterBufferCount,
6460 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6461 }
6462
6463 return skip;
6464}
6465
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006466bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6467 uint32_t firstInstance, VkBuffer counterBuffer,
6468 VkDeviceSize counterBufferOffset,
6469 uint32_t counterOffset, uint32_t vertexStride) const {
6470 bool skip = false;
6471
6472 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006473 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6474 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6475 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6476 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006477 }
6478
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006479 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006480 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006481 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006482 }
6483
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006484 return skip;
6485}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006486
6487bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6488 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6489 const VkAllocationCallbacks *pAllocator,
6490 VkSamplerYcbcrConversion *pYcbcrConversion,
6491 const char *apiName) const {
6492 bool skip = false;
6493
6494 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006495 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006496 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006497 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006498 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6499 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006500 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006501 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006502 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006503
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006504#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006505 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006506 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006507#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006508 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006509#endif
6510
sfricke-samsung1a72f942020-07-25 12:09:18 -07006511 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006512
6513 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006514 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006515 const VkComponentMapping components = pCreateInfo->components;
6516 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6517 if (FormatIsXChromaSubsampled(format) == true) {
6518 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6519 skip |=
6520 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006521 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6522 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006523 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006524 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006525
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006526 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6527 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6528 skip |= LogError(
6529 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6530 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6531 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6532 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6533 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006534
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006535 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6536 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6537 skip |=
6538 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006539 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6540 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006541 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006542 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006543
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006544 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6545 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6546 skip |=
6547 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006548 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6549 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006550 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006551 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006552
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006553 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006554 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6555 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6556 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006557 skip |=
6558 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006559 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6560 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006561 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6562 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006563 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006564 }
6565
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006566 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6567 // Checks same VU multiple ways in order to give a more useful error message
6568 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6569 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6570 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6571 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6572 skip |= LogError(
6573 device, vuid,
6574 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6575 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6576 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6577 string_VkComponentSwizzle(components.b));
6578 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006579
sfricke-samsunged028b02021-09-06 23:14:51 -07006580 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6581 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006582 // 3 = no [a]
6583 // 2 = no [b,a]
6584 // 1 = no [g,b,a]
6585 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006586 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006587
sfricke-samsunged028b02021-09-06 23:14:51 -07006588 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6589 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006590 skip |= LogError(device, vuid,
6591 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6592 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6593 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6594 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006595 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006596 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6597 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6598 skip |= LogError(device, vuid,
6599 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6600 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6601 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6602 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6603 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006604 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006605 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6606 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6607 skip |= LogError(device, vuid,
6608 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6609 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6610 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6611 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6612 string_VkComponentSwizzle(components.b));
6613 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006614 }
6615 }
6616
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006617 return skip;
6618}
6619
6620bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6621 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6622 const VkAllocationCallbacks *pAllocator,
6623 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6624 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6625 "vkCreateSamplerYcbcrConversion");
6626}
6627
6628bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6629 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6630 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6631 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6632 "vkCreateSamplerYcbcrConversionKHR");
6633}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006634
6635bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6636 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6637 bool skip = false;
6638 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6639 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6640
6641 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006642 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6643 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6644 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6645 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6646 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006647 }
6648 return skip;
6649}
sourav parmara96ab1a2020-04-25 16:28:23 -07006650
6651bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006652 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006653 bool skip = false;
6654 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6655 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6656 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6657 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006658 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006659 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6660 skip |= LogError(
6661 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6662 "vkCopyAccelerationStructureToMemoryKHR: The "
6663 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6664 }
6665 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6666 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6667 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6668 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6669 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6670 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006671 return skip;
6672}
6673
6674bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6675 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6676 bool skip = false;
6677 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6678 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6679 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6680 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6681 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006682 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6683 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006684 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006685 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006686 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006687 return skip;
6688}
6689
6690bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6691 const char *api_name) const {
6692 bool skip = false;
6693 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6694 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6695 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6696 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6697 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6698 api_name);
6699 }
6700 return skip;
6701}
6702
6703bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006704 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006705 bool skip = false;
6706 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006707 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006708 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006709 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006710 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6711 "vkCopyAccelerationStructureKHR: The "
6712 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006713 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006714 return skip;
6715}
6716
6717bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6718 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6719 bool skip = false;
6720 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6721 return skip;
6722}
6723
6724bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006725 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006726 bool skip = false;
6727 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006728 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006729 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6730 }
6731 return skip;
6732}
6733
6734bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006735 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006736 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006737 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006738 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006739 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6740 skip |= LogError(
6741 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6742 "vkCopyMemoryToAccelerationStructureKHR: The "
6743 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006744 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006745 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6746 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006747 return skip;
6748}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006749
sourav parmara96ab1a2020-04-25 16:28:23 -07006750bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6751 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6752 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006753 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006754 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6755 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006756 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006757 pInfo->src.deviceAddress);
6758 }
sourav parmar83c31b12020-05-06 12:30:54 -07006759 return skip;
6760}
6761bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6762 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6763 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6764 bool skip = false;
6765 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6766 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6767 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6768 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6769 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6770 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6771 }
6772 return skip;
6773}
6774bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6775 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6776 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6777 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006778 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006779 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6780 skip |= LogError(
6781 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6782 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6783 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6784 }
sourav parmar83c31b12020-05-06 12:30:54 -07006785 if (dataSize < accelerationStructureCount * stride) {
6786 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6787 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006788 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006789 dataSize, accelerationStructureCount, stride);
6790 }
6791 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6792 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6793 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6794 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6795 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6796 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6797 }
6798 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6799 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6800 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6801 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6802 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6803 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6804 stride);
6805 }
6806 }
6807 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6808 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6809 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6810 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6811 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6812 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6813 stride);
6814 }
6815 }
sourav parmar83c31b12020-05-06 12:30:54 -07006816 return skip;
6817}
6818bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6819 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6820 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006821 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006822 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6823 skip |= LogError(
6824 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6825 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6826 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006827 }
6828 return skip;
6829}
6830
6831bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006832 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6833 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6834 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6835 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006836 uint32_t width, uint32_t height, uint32_t depth) const {
6837 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006838 // RayGen
6839 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6840 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6841 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006842 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006843 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6844 0) {
6845 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6846 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6847 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6848 }
6849 // Callable
6850 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6851 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6852 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6853 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006854 }
6855 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6856 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6857 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006858 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6859 }
6860 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6861 0) {
6862 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6863 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6864 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006865 }
6866 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006867 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6868 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6869 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6870 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006871 }
6872 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6873 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006874 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6875 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006876 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006877 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6878 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6879 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6880 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6881 }
sourav parmar83c31b12020-05-06 12:30:54 -07006882 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006883 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6884 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6885 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6886 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006887 }
6888 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6889 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6890 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006891 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6892 }
6893 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6894 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6895 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6896 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6897 }
6898 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6899 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6900 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6901 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6902 }
6903 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6904 skip |=
6905 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6906 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6907 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006908 }
6909
sourav parmarcd5fb182020-07-17 12:58:44 -07006910 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6911 skip |=
6912 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6913 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6914 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6915 }
6916
6917 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6918 skip |=
6919 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6920 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6921 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006922 }
6923 return skip;
6924}
6925
sourav parmarcd5fb182020-07-17 12:58:44 -07006926bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6927 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6928 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6929 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006930 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006931 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006932 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6933 skip |= LogError(
6934 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6935 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6936 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006937 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006938 // RayGen
6939 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6940 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6941 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006942 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006943 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6944 0) {
6945 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6946 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6947 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6948 }
6949 // Callabe
6950 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6951 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6952 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6953 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006954 }
6955 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6956 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006957 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6958 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6959 }
6960 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6961 0) {
6962 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6963 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6964 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006965 }
6966 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006967 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6968 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6969 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6970 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006971 }
6972 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6973 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006974 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6975 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006976 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006977 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6978 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6979 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6980 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6981 }
sourav parmar83c31b12020-05-06 12:30:54 -07006982 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006983 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6984 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6985 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6986 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006987 }
6988 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6989 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006990 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6991 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6992 }
6993 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6994 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6995 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6996 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006997 }
6998
sourav parmarcd5fb182020-07-17 12:58:44 -07006999 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
7000 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
7001 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07007002 }
7003 return skip;
7004}
7005bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
7006 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
7007 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
7008 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
7009 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
7010 uint32_t width, uint32_t height, uint32_t depth) const {
7011 bool skip = false;
7012 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7013 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
7014 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
7015 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7016 }
7017 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7018 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
7019 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
7020 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7021 }
7022 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7023 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
7024 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
7025 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
7026 }
7027
7028 // hitShader
7029 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7030 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7031 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7032 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7033 }
7034 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7035 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7036 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7037 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7038 }
7039 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7040 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7041 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7042 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7043 }
7044
7045 // missShader
7046 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7047 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7048 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7049 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7050 }
7051 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7052 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7053 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7054 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7055 }
7056 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7057 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7058 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7059 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7060 }
7061
7062 // raygenShader
7063 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7064 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7065 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007066 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7067 }
7068 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7069 skip |=
7070 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7071 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7072 }
7073 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7074 skip |=
7075 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7076 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7077 }
7078 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7079 skip |=
7080 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7081 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007082 }
7083 return skip;
7084}
7085
sourav parmar83c31b12020-05-06 12:30:54 -07007086bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007087 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7088 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007089 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007090 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7091 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007092 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7093 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007094 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007095 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7096 }
7097 return skip;
7098}
7099
Piers Daniell39842ee2020-07-10 16:42:33 -06007100bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7101 const VkViewport *pViewports) const {
7102 bool skip = false;
7103
7104 if (!physical_device_features.multiViewport) {
7105 if (viewportCount != 1) {
7106 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
7107 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
7108 ") is not 1.",
7109 viewportCount);
7110 }
7111 } else { // multiViewport enabled
7112 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
7113 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
7114 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
7115 ") must "
7116 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
7117 viewportCount, device_limits.maxViewports);
7118 }
7119 }
7120
7121 if (pViewports) {
7122 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7123 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
7124 const char *fn_name = "vkCmdSetViewportWithCountEXT";
7125 skip |= manual_PreCallValidateViewport(
7126 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
7127 }
7128 }
7129
7130 return skip;
7131}
7132
7133bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7134 const VkRect2D *pScissors) const {
7135 bool skip = false;
7136
7137 if (!physical_device_features.multiViewport) {
7138 if (scissorCount != 1) {
7139 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
7140 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7141 ") must "
7142 "be 1 when the multiViewport feature is disabled.",
7143 scissorCount);
7144 }
7145 } else { // multiViewport enabled
7146 if (scissorCount == 0) {
7147 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7148 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7149 ") must "
7150 "be great than zero.",
7151 scissorCount);
7152 } else if (scissorCount > device_limits.maxViewports) {
7153 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7154 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7155 ") must "
7156 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
7157 scissorCount, device_limits.maxViewports);
7158 }
7159 }
7160
7161 if (pScissors) {
7162 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7163 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7164
7165 if (scissor.offset.x < 0) {
7166 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7167 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
7168 scissor.offset.x);
7169 }
7170
7171 if (scissor.offset.y < 0) {
7172 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7173 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
7174 scissor.offset.y);
7175 }
7176
7177 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7178 if (x_sum > INT32_MAX) {
7179 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
7180 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7181 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7182 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
7183 }
7184
7185 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7186 if (y_sum > INT32_MAX) {
7187 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
7188 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7189 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7190 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7191 }
7192 }
7193 }
7194
7195 return skip;
7196}
7197
7198bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7199 uint32_t bindingCount, const VkBuffer *pBuffers,
7200 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7201 const VkDeviceSize *pStrides) const {
7202 bool skip = false;
7203 if (firstBinding >= device_limits.maxVertexInputBindings) {
7204 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007205 "vkCmdBindVertexBuffers2EXT() firstBinding (%" PRIu32
7206 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007207 firstBinding, device_limits.maxVertexInputBindings);
7208 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7209 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007210 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7211 ") must be less than "
7212 "maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007213 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7214 }
7215
7216 for (uint32_t i = 0; i < bindingCount; ++i) {
7217 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007218 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06007219 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007220 skip |= LogError(
7221 commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
7222 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007223 } else {
7224 if (pOffsets[i] != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007225 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
7226 "vkCmdBindVertexBuffers2EXT() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
7227 "] is not 0",
7228 i, i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007229 }
7230 }
7231 }
7232 if (pStrides) {
7233 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007234 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
7235 "vkCmdBindVertexBuffers2EXT() pStrides[%" PRIu32 "] (%" PRIu64
7236 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7237 i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007238 }
7239 }
7240 }
7241
7242 return skip;
7243}
sourav parmarcd5fb182020-07-17 12:58:44 -07007244
7245bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7246 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7247 bool skip = false;
7248 for (uint32_t i = 0; i < infoCount; ++i) {
7249 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7250 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7251 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7252 }
7253 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7254 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7255 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7256 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7257 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7258 api_name);
7259 }
7260 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7261 skip |=
7262 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7263 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7264 }
7265 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7266 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7267 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7268 }
7269 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7270 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7271 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7272 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7273 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7274 api_name);
7275 }
7276 if (pInfos[i].pGeometries) {
7277 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7278 skip |= validate_ranged_enum(
7279 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7280 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7281 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7282 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007283 skip |= validate_struct_type(
7284 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7285 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7286 &(pInfos[i].pGeometries[j].geometry.triangles),
7287 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7288 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7289 skip |= validate_struct_pnext(
7290 api_name,
7291 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7292 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7293 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7294 skip |=
7295 validate_ranged_enum(api_name,
7296 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7297 ParameterName::IndexVector{i, j}),
7298 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7299 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7300 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7301 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7302 &pInfos[i].pGeometries[j].geometry.triangles,
7303 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7304 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7305 skip |= validate_ranged_enum(
7306 api_name,
7307 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7308 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7309 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7310
7311 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7312 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7313 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7314 }
7315 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7316 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7317 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7318 skip |=
7319 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7320 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7321 api_name);
7322 }
7323 }
7324 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7325 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7326 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7327 &pInfos[i].pGeometries[j].geometry.instances,
7328 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7329 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7330 skip |= validate_struct_type(
7331 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7332 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7333 &(pInfos[i].pGeometries[j].geometry.instances),
7334 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7335 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7336 skip |= validate_struct_pnext(
7337 api_name,
7338 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7339 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7340 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7341
7342 skip |= validate_bool32(api_name,
7343 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7344 ParameterName::IndexVector{i, j}),
7345 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7346 }
7347 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7348 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7349 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7350 &pInfos[i].pGeometries[j].geometry.aabbs,
7351 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7352 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7353 skip |= validate_struct_type(
7354 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7355 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7356 &(pInfos[i].pGeometries[j].geometry.aabbs),
7357 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7358 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7359 skip |= validate_struct_pnext(
7360 api_name,
7361 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7362 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7363 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7364 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7365 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7366 "(%s):stride must be less than or equal to 2^32-1", api_name);
7367 }
7368 }
7369 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7370 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7371 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7372 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7373 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7374 api_name);
7375 }
7376 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7377 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7378 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7379 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7380 "of elements of"
7381 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7382 api_name);
7383 }
7384 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7385 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7386 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7387 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7388 api_name);
7389 }
7390 }
7391 }
7392 }
7393 if (pInfos[i].ppGeometries != NULL) {
7394 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7395 skip |= validate_ranged_enum(
7396 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7397 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7398 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7399 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007400 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7401 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7402 &pInfos[i].ppGeometries[j]->geometry.triangles,
7403 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7404 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7405 skip |= validate_struct_type(
7406 api_name,
7407 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7408 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7409 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7410 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7411 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7412 skip |= validate_struct_pnext(
7413 api_name,
7414 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7415 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7416 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7417 skip |= validate_ranged_enum(api_name,
7418 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7419 ParameterName::IndexVector{i, j}),
7420 "VkFormat", AllVkFormatEnums,
7421 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7422 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7423 skip |= validate_ranged_enum(api_name,
7424 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7425 ParameterName::IndexVector{i, j}),
7426 "VkIndexType", AllVkIndexTypeEnums,
7427 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7428 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7429 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7430 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7431 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7432 }
7433 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7434 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7435 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7436 skip |=
7437 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7438 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7439 api_name);
7440 }
7441 }
7442 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7443 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7444 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7445 &pInfos[i].ppGeometries[j]->geometry.instances,
7446 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7447 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7448 skip |= validate_struct_type(
7449 api_name,
7450 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7451 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7452 &(pInfos[i].ppGeometries[j]->geometry.instances),
7453 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7454 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7455 skip |= validate_struct_pnext(
7456 api_name,
7457 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7458 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7459 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7460 skip |= validate_bool32(api_name,
7461 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7462 ParameterName::IndexVector{i, j}),
7463 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7464 }
7465 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7466 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7467 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7468 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7469 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7470 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7471 skip |= validate_struct_type(
7472 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7473 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7474 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7475 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7476 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7477 skip |= validate_struct_pnext(
7478 api_name,
7479 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7480 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7481 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7482 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7483 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7484 "(%s):stride must be less than or equal to 2^32-1", api_name);
7485 }
7486 }
7487 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7488 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7489 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7490 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7491 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7492 api_name);
7493 }
7494 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7495 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7496 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7497 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7498 "of elements of"
7499 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7500 api_name);
7501 }
7502 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7503 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7504 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7505 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7506 api_name);
7507 }
7508 }
7509 }
7510 }
7511 }
7512 return skip;
7513}
7514bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7515 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7516 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7517 bool skip = false;
7518 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7519 for (uint32_t i = 0; i < infoCount; ++i) {
7520 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7521 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7522 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7523 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7524 "scratchData.deviceAddress member must be a multiple of "
7525 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7526 }
7527 for (uint32_t k = 0; k < infoCount; ++k) {
7528 if (i == k) continue;
7529 bool found = false;
7530 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007531 skip |=
7532 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7533 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7534 ") of pInfos must "
7535 "not be "
7536 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7537 ") of pInfos.",
7538 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007539 found = true;
7540 }
7541 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007542 skip |=
7543 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7544 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7545 ") of pInfos must "
7546 "not be "
7547 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7548 ") of pInfos.",
7549 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007550 found = true;
7551 }
7552 if (found) break;
7553 }
7554 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7555 if (pInfos[i].pGeometries) {
7556 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7557 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7558 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7559 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7560 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7561 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7562 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7563 }
7564 } else {
7565 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7566 skip |=
7567 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7568 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7569 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7570 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7571 }
7572 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007573 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007574 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7575 skip |= LogError(
7576 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7577 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7578 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7579 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007580 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7581 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007582 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7583 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7584 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7585 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7586 }
7587 }
7588 } else if (pInfos[i].ppGeometries) {
7589 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7590 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7591 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7592 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7593 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7594 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7595 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7596 }
7597 } else {
7598 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7599 skip |=
7600 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7601 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7602 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7603 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7604 }
7605 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007606 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007607 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7608 skip |= LogError(
7609 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7610 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7611 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7612 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007613 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7614 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007615 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7616 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7617 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7618 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7619 }
7620 }
7621 }
7622 }
7623 }
7624 return skip;
7625}
7626
7627bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7628 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7629 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7630 const uint32_t *const *ppMaxPrimitiveCounts) const {
7631 bool skip = false;
7632 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7633 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007634 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007635 if (!ray_tracing_acceleration_structure_features ||
7636 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7637 skip |= LogError(
7638 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7639 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7640 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7641 }
7642 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007643 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7644 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7645 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7646 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7647 "scratchData.deviceAddress member must be a multiple of "
7648 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7649 }
7650 for (uint32_t k = 0; k < infoCount; ++k) {
7651 if (i == k) continue;
7652 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007653 skip |= LogError(
7654 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7655 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7656 ") "
7657 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7658 "any other element [%" PRIu32 ") of pInfos.",
7659 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007660 break;
7661 }
7662 }
7663 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7664 if (pInfos[i].pGeometries) {
7665 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7666 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7667 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7668 skip |= LogError(
7669 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7670 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7671 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7672 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7673 }
7674 } else {
7675 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7676 skip |= LogError(
7677 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7678 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7679 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7680 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7681 }
7682 }
7683 }
7684 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7685 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7686 skip |= LogError(
7687 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7688 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7689 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7690 }
7691 }
7692 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7693 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7694 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7695 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7696 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7697 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7698 }
7699 }
7700 } else if (pInfos[i].ppGeometries) {
7701 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7702 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7703 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7704 skip |= LogError(
7705 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7706 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7707 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7708 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7709 }
7710 } else {
7711 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7712 skip |= LogError(
7713 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7714 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7715 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7716 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7717 }
7718 }
7719 }
7720 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7721 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7722 skip |= LogError(
7723 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7724 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7725 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7726 }
7727 }
7728 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7729 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7730 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7731 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7732 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7733 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7734 }
7735 }
7736 }
7737 }
7738 }
7739 return skip;
7740}
7741
7742bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7743 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7744 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7745 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7746 bool skip = false;
7747 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7748 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007749 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007750 if (!ray_tracing_acceleration_structure_features ||
7751 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7752 skip |=
7753 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7754 "vkBuildAccelerationStructuresKHR: The "
7755 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7756 }
7757 for (uint32_t i = 0; i < infoCount; ++i) {
7758 for (uint32_t j = 0; j < infoCount; ++j) {
7759 if (i == j) continue;
7760 bool found = false;
7761 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007762 skip |=
7763 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7764 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7765 ") of pInfos must "
7766 "not be "
7767 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7768 ") of pInfos.",
7769 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007770 found = true;
7771 }
7772 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007773 skip |=
7774 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7775 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7776 ") of pInfos must "
7777 "not be "
7778 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7779 ") of pInfos.",
7780 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007781 found = true;
7782 }
7783 if (found) break;
7784 }
7785 }
7786 return skip;
7787}
7788
7789bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7790 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7791 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7792 bool skip = false;
7793 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7794 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007795 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7796 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007797 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7798 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7799 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7800 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01007801 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
7802 }
7803 if (pBuildInfo != nullptr) {
7804 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
7805 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
7806 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
7807 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
7808 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007809 }
7810 return skip;
7811}
sfricke-samsungecafb192021-01-17 08:21:14 -08007812
7813bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7814 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7815 const VkAllocationCallbacks *pAllocator,
7816 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7817 bool skip = false;
7818 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7819 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7820 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7821 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7822 }
7823 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007824}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007825
7826bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7827 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7828 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7829 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7830 bool skip = false;
7831 const auto *vertex_input_dynamic_state_features =
7832 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7833 const auto *vertex_attribute_divisor_features =
7834 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7835
7836 // VUID-vkCmdSetVertexInputEXT-None-04790
7837 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7838 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7839 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7840 }
7841
7842 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7843 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7844 skip |=
7845 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7846 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7847 }
7848
7849 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7850 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7851 skip |= LogError(
7852 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7853 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7854 }
7855
7856 // VUID-vkCmdSetVertexInputEXT-binding-04793
7857 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7858 bool binding_found = false;
7859 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7860 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7861 binding_found = true;
7862 break;
7863 }
7864 }
7865 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007866 skip |= LogError(
7867 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7868 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007869 }
7870 }
7871
7872 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7873 if (vertexBindingDescriptionCount > 1) {
7874 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7875 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7876 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7877 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7878 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007879 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7880 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007881 }
7882 }
7883 }
7884 }
7885
7886 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7887 if (vertexAttributeDescriptionCount > 1) {
7888 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7889 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7890 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7891 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7892 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007893 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7894 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007895 }
7896 }
7897 }
7898 }
7899
7900 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7901 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7902 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007903 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7904 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7905 "].binding is greater than maxVertexInputBindings",
7906 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007907 }
7908
7909 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7910 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007911 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7912 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7913 "].stride is greater than maxVertexInputBindingStride",
7914 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007915 }
7916
7917 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7918 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7919 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7920 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007921 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7922 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007923 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7924 binding);
7925 }
7926
7927 if (pVertexBindingDescriptions[binding].divisor > 1) {
7928 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7929 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7930 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007931 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7932 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007933 "vertexAttributeInstanceRateDivisor is not enabled",
7934 binding);
7935 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007936 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007937 if (pVertexBindingDescriptions[binding].divisor >
7938 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007939 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
7940 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7941 "].divisor is greater than maxVertexAttribDivisor",
7942 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007943 }
7944
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007945 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007946 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007947 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
7948 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7949 "].divisor is greater than 1 but inputRate "
7950 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7951 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007952 }
7953 }
7954 }
7955 }
7956
7957 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007958 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007959 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007960 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
7961 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7962 "].location is greater than maxVertexInputAttributes",
7963 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007964 }
7965
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007966 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007967 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007968 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
7969 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7970 "].binding is greater than maxVertexInputBindings",
7971 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007972 }
7973
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007974 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007975 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007976 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
7977 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7978 "].offset is greater than maxVertexInputAttributeOffset",
7979 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007980 }
7981
7982 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7983 VkFormatProperties properties;
7984 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7985 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7986 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007987 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7988 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007989 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7990 attribute);
7991 }
7992 }
7993
7994 return skip;
7995}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007996
7997bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7998 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7999 const void *pValues) const {
8000 bool skip = false;
8001 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
8002 // Check that offset + size don't exceed the max.
8003 // Prevent arithetic overflow here by avoiding addition and testing in this order.
8004 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008005 skip |=
8006 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
8007 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
8008 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008009 }
8010 if (size > max_push_constants_size - offset) {
8011 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008012 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
8013 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07008014 offset, size, max_push_constants_size);
8015 }
8016
8017 // size needs to be non-zero and a multiple of 4.
8018 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008019 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
8020 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008021 }
8022
8023 // offset needs to be a multiple of 4.
8024 if ((offset & 0x3) != 0) {
8025 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07008026 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07008027 }
8028 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008029}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008030
8031bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8032 uint32_t srcCacheCount,
8033 const VkPipelineCache *pSrcCaches) const {
8034 bool skip = false;
8035 if (pSrcCaches) {
8036 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8037 if (pSrcCaches[index0] == dstCache) {
8038 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8039 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8040 report_data->FormatHandle(dstCache).c_str());
8041 break;
8042 }
8043 }
8044 }
8045 return skip;
8046}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008047
8048bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8049 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8050 uint32_t rangeCount,
8051 const VkImageSubresourceRange *pRanges) const {
8052 bool skip = false;
8053 if (!pColor) {
8054 skip |=
8055 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8056 }
8057 return skip;
8058}
8059
8060bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8061 const VkRenderPassBeginInfo *const rp_begin) const {
8062 bool skip = false;
8063 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8064 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8065 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008066 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008067 func_name, rp_begin->clearValueCount);
8068 }
8069 return skip;
8070}
8071
8072bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8073 VkSubpassContents) const {
8074 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8075 return skip;
8076}
8077
8078bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8079 const VkRenderPassBeginInfo *pRenderPassBegin,
8080 const VkSubpassBeginInfo *) const {
8081 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8082 return skip;
8083}
8084
8085bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8086 const VkSubpassBeginInfo *) const {
8087 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8088 return skip;
8089}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008090
8091bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8092 uint32_t firstDiscardRectangle,
8093 uint32_t discardRectangleCount,
8094 const VkRect2D *pDiscardRectangles) const {
8095 bool skip = false;
8096
8097 if (pDiscardRectangles) {
8098 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8099 const int64_t x_sum =
8100 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8101 if (x_sum > std::numeric_limits<int32_t>::max()) {
8102 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8103 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8104 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8105 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8106 }
8107
8108 const int64_t y_sum =
8109 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8110 if (y_sum > std::numeric_limits<int32_t>::max()) {
8111 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8112 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8113 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8114 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8115 }
8116 }
8117 }
8118
8119 return skip;
8120}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008121
8122bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8123 uint32_t queryCount, size_t dataSize, void *pData,
8124 VkDeviceSize stride, VkQueryResultFlags flags) const {
8125 bool skip = false;
8126
8127 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8128 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8129 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8130 }
8131
8132 return skip;
8133}
ziga-lunargcf340c42021-08-19 00:13:38 +02008134
8135bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8136 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8137 bool skip = false;
8138
8139 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8140 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8141 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8142 ") is not a multiple of 4.",
8143 pConditionalRenderingBegin->offset);
8144 }
8145
8146 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008147}
Mike Schuchardt05b028d2022-01-05 14:15:00 -08008148
8149bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
8150 VkSurfaceKHR surface,
8151 uint32_t *pSurfaceFormatCount,
8152 VkSurfaceFormatKHR *pSurfaceFormats) const {
8153 bool skip = false;
8154 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8155 skip |= LogError(
8156 physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormatsKHR-surface-06524",
8157 "vkGetPhysicalDeviceSurfaceFormatsKHR(): surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8158 }
8159 return skip;
8160}
8161
8162bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
8163 VkSurfaceKHR surface,
8164 uint32_t *pPresentModeCount,
8165 VkPresentModeKHR *pPresentModes) const {
8166 bool skip = false;
8167 if (surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8168 skip |= LogError(
8169 physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModesKHR-surface-06524",
8170 "vkGetPhysicalDeviceSurfacePresentModesKHR: surface is VK_NULL_HANDLE and VK_GOOGLE_surfaceless_query is not enabled.");
8171 }
8172 return skip;
8173}
8174
8175bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceCapabilities2KHR(
8176 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
8177 VkSurfaceCapabilities2KHR *pSurfaceCapabilities) const {
8178 bool skip = false;
8179 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8180 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceCapabilities2KHR-pSurfaceInfo-06520",
8181 "vkGetPhysicalDeviceSurfaceCapabilities2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8182 "VK_GOOGLE_surfaceless_query is not enabled.");
8183 }
8184 return skip;
8185}
8186
8187bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfaceFormats2KHR(
8188 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount,
8189 VkSurfaceFormat2KHR *pSurfaceFormats) const {
8190 bool skip = false;
8191 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8192 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfaceFormats2KHR-pSurfaceInfo-06521",
8193 "vkGetPhysicalDeviceSurfaceFormats2KHR: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8194 "VK_GOOGLE_surfaceless_query is not enabled.");
8195 }
8196 return skip;
8197}
8198
8199#ifdef VK_USE_PLATFORM_WIN32_KHR
8200bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceSurfacePresentModes2EXT(
8201 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pPresentModeCount,
8202 VkPresentModeKHR *pPresentModes) const {
8203 bool skip = false;
8204 if (pSurfaceInfo && pSurfaceInfo->surface == VK_NULL_HANDLE && !instance_extensions.vk_google_surfaceless_query) {
8205 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceSurfacePresentModes2EXT-pSurfaceInfo-06521",
8206 "vkGetPhysicalDeviceSurfacePresentModes2EXT: pSurfaceInfo->surface is VK_NULL_HANDLE and "
8207 "VK_GOOGLE_surfaceless_query is not enabled.");
8208 }
8209 return skip;
8210}
8211#endif // VK_USE_PLATFORM_WIN32_KHR