blob: b3639ddc98462f16967079865c8403a2106d828e [file] [log] [blame]
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 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 {
Mike Schuchardt7cc57842021-09-15 10:49:59 -0700381 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME));
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700382 bool negative_viewport =
383 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200384 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700385 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
386 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
387 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200388 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600389 }
390
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600391 {
ziga-lunarg9271a7c2021-07-19 16:37:06 +0200392 bool khr_bda =
393 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
394 bool ext_bda =
395 IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600396 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700397 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
398 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
399 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600400 }
401 }
402
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600403 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
404 // Check for get_physical_device_properties2 struct
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700405 const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600406 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800407 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700408 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800409 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700410 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600411 }
412 }
413
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700414 auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500415 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700416 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500417 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
418 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
419 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
420 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700421 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext);
sourav parmarcd5fb182020-07-17 12:58:44 -0700422 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed &&
423 !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) {
424 skip |= LogError(
425 device,
426 "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575",
427 "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay "
428 "must also be VK_TRUE.");
sourav parmara24fb7b2020-05-26 10:50:04 -0700429 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700430 auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -0700431 if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) {
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600432 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
433 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
434 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600435 }
436
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700437 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700438 if (vulkan_11_features) {
439 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
440 while (current) {
441 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
442 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
443 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
444 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
445 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
446 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700447 skip |= LogError(
448 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700449 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
450 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
451 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
452 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
453 break;
454 }
455 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
456 }
sfricke-samsungebda6792021-01-16 08:57:52 -0800457
458 // Check features are enabled if matching extension is passed in as well
459 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
460 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
461 if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
462 (vulkan_11_features->shaderDrawParameters == VK_FALSE)) {
463 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800464 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476",
sfricke-samsungebda6792021-01-16 08:57:52 -0800465 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.",
466 VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
467 }
468 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700469 }
470
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700471 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
Tony-LunarG28017bc2020-01-23 14:40:25 -0700472 if (vulkan_12_features) {
473 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
474 while (current) {
475 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
476 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
477 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
478 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
479 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
480 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
481 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
482 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
483 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
484 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
485 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
486 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
487 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700488 skip |= LogError(
489 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700490 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
491 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
492 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
493 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
494 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
495 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
496 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
497 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
498 break;
499 }
500 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
501 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700502 // Check features are enabled if matching extension is passed in as well
503 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
504 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
505 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
506 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
507 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800508 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831",
sfricke-samsungabab4632020-05-04 06:51:46 -0700509 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
510 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
511 }
512 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
513 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
Mike Schuchardt9969d022021-12-20 15:51:55 -0800514 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832",
sfricke-samsungabab4632020-05-04 06:51:46 -0700515 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
516 "is not VK_TRUE.",
517 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
518 }
519 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
520 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
521 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800522 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833",
sfricke-samsungabab4632020-05-04 06:51:46 -0700523 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
524 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
525 }
526 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
527 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
528 skip |= LogError(
Mike Schuchardt9969d022021-12-20 15:51:55 -0800529 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834",
sfricke-samsungabab4632020-05-04 06:51:46 -0700530 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
531 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
532 }
533 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
534 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
535 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
536 skip |=
Mike Schuchardt9969d022021-12-20 15:51:55 -0800537 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835",
sfricke-samsungabab4632020-05-04 06:51:46 -0700538 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
539 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
540 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
541 }
542 }
ziga-lunarg27f88fd2021-08-01 15:47:30 +0200543 if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) {
544 if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) {
545 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748",
546 "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress "
547 "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address");
548 }
549 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700550 }
551
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600552 // Validate pCreateInfo->pQueueCreateInfos
553 if (pCreateInfo->pQueueCreateInfos) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600554
555 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700556 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
557 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600558 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700559 skip |=
560 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
561 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
562 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
563 "index value.",
564 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600565 }
566
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700567 if (queue_create_info.pQueuePriorities != nullptr) {
568 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
569 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700571 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
572 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
573 "] (=%f) is not between 0 and 1 (inclusive).",
574 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600575 }
576 }
577 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700578
579 // Need to know if protectedMemory feature is passed in preCall to creating the device
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700580 VkBool32 protected_memory = VK_FALSE;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700581 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700582 LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700583 if (protected_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700584 protected_memory = protected_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700585 } else if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700586 protected_memory = vulkan_11_features->protectedMemory;
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700587 }
Mike Schuchardta9101d32021-11-12 12:24:08 -0800588 if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700589 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
Mike Schuchardta9101d32021-11-12 12:24:08 -0800590 "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
591 "protectedMemory feature being enabled as well.");
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700592 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600593 }
594 }
595
sfricke-samsung30a57412020-05-15 21:14:54 -0700596 // feature dependencies for VK_KHR_variable_pointers
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700597 const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700598 VkBool32 variable_pointers = VK_FALSE;
599 VkBool32 variable_pointers_storage_buffer = VK_FALSE;
sfricke-samsung30a57412020-05-15 21:14:54 -0700600 if (vulkan_11_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700601 variable_pointers = vulkan_11_features->variablePointers;
602 variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700603 } else if (variable_pointers_features) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700604 variable_pointers = variable_pointers_features->variablePointers;
605 variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer;
sfricke-samsung30a57412020-05-15 21:14:54 -0700606 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700607 if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) {
sfricke-samsung30a57412020-05-15 21:14:54 -0700608 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
609 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
610 }
611
sfricke-samsungfd76c342020-05-29 23:13:43 -0700612 // feature dependencies for VK_KHR_multiview
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700613 const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
sfricke-samsungfd76c342020-05-29 23:13:43 -0700614 VkBool32 multiview = VK_FALSE;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700615 VkBool32 multiview_geometry_shader = VK_FALSE;
616 VkBool32 multiview_tessellation_shader = VK_FALSE;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700617 if (vulkan_11_features) {
618 multiview = vulkan_11_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700619 multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader;
620 multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700621 } else if (multiview_features) {
622 multiview = multiview_features->multiview;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700623 multiview_geometry_shader = multiview_features->multiviewGeometryShader;
624 multiview_tessellation_shader = multiview_features->multiviewTessellationShader;
sfricke-samsungfd76c342020-05-29 23:13:43 -0700625 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700626 if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700627 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
628 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
629 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700630 if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) {
sfricke-samsungfd76c342020-05-29 23:13:43 -0700631 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
632 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
633 }
634
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600635 return skip;
636}
637
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500638bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700639 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700640 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
641 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
642 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600643 }
644
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700645 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646}
647
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700648bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500649 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100650 bool skip = false;
651
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600652 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |=
654 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600655
656 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
657 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
658 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
659 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700660 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
661 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
662 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600663 }
664
665 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
666 // queueFamilyIndexCount uint32_t values
667 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
669 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
670 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
671 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600672 }
673 }
674
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700675 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
676 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
677 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
678 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
679 }
680
681 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
682 skip |=
683 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
684 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
685 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
686 }
687
688 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
689 skip |=
690 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
691 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
692 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
693 }
694
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600695 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
696 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
697 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
698 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700699 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
700 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
701 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600702 }
Piers Daniella7f93b62021-11-20 12:32:04 -0700703
704 const auto *maintenance4_features = LvlFindInChain<VkPhysicalDeviceMaintenance4FeaturesKHR>(device_createinfo_pnext);
705 if (maintenance4_features && maintenance4_features->maintenance4) {
706 if (pCreateInfo->size > phys_dev_ext_props.maintenance4_props.maxBufferSize) {
707 skip |= LogError(device, "VUID-VkBufferCreateInfo-size-06409",
708 "vkCreateBuffer: pCreateInfo->size is larger than the maximum allowed buffer size "
709 "VkPhysicalDeviceMaintenance4Properties.maxBufferSize");
710 }
711 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600712 }
713
714 return skip;
715}
716
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700717bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500718 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600720
721 if (pCreateInfo != nullptr) {
sfricke-samsung61a57c02021-01-10 21:35:12 -0800722 const VkFormat image_format = pCreateInfo->format;
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700723 const VkImageCreateFlags image_flags = pCreateInfo->flags;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600724 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
725 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
726 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
727 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
729 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
730 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731 }
732
733 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
734 // queueFamilyIndexCount uint32_t values
735 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700736 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
737 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
738 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
739 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600740 }
741 }
742
Dave Houlton413a6782018-05-22 13:01:54 -0600743 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600745 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700746 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600747 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700748 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600749
Dave Houlton413a6782018-05-22 13:01:54 -0600750 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700751 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600752 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700753 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600754
Dave Houlton130c0212018-01-29 13:39:56 -0700755 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700756 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
757 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(
759 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600760 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
761 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700762 }
763
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600764 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100765 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
766 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700767 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
768 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
769 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600770 }
771
772 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700773 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
Petr Kraus3f433212018-03-13 12:31:27 +0100774 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700775 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
776 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
777 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
778 ") are not equal.",
779 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100780 }
781
782 if (pCreateInfo->arrayLayers < 6) {
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->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
786 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100787 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600788 }
789
790 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(
792 device, "VUID-VkImageCreateInfo-imageType-00957",
793 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600794 }
795 }
796
Dave Houlton130c0212018-01-29 13:39:56 -0700797 // 3D image may have only 1 layer
798 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700799 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
800 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700801 }
802
Dave Houlton130c0212018-01-29 13:39:56 -0700803 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
804 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
805 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
806 // At least one of the legal attachment bits must be set
807 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700808 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
809 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700810 }
811 // No flags other than the legal attachment bits may be set
812 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
813 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700814 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
815 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700816 }
817 }
818
Jeff Bolzef40fec2018-09-01 22:04:34 -0500819 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700820 uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500821 // Max mip levels is different for corner-sampled images vs normal images.
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700822 uint32_t max_mip_levels = (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV)
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -0700823 ? static_cast<uint32_t>(ceil(log2(max_dim)))
824 : static_cast<uint32_t>(floor(log2(max_dim)) + 1);
825 if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600826 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700827 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
828 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
829 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600830 }
831
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700832 if ((image_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700833 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
834 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
835 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600836 }
837
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700838 if ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700839 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
840 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
841 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100842 }
843
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700844 if ((image_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700845 skip |= LogError(
846 device, "VUID-VkImageCreateInfo-flags-01924",
847 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
848 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
849 }
850
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600851 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
852 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700853 if (((image_flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
854 ((image_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700855 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
856 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
857 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600858 }
859
860 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700861 if ((image_flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600862 // Linear tiling is unsupported
863 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700864 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700865 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
866 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600867 }
868
869 // Sparse 1D image isn't valid
870 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700871 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
872 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600873 }
874
875 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700876 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700877 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
878 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
879 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600880 }
881
882 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700883 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700884 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
885 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
886 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600887 }
888
889 // Multi-sample 2D image when device doesn't support it
890 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700891 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600892 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700893 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
894 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
895 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700896 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600897 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700898 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
899 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
900 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700901 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600902 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700903 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
904 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
905 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700906 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600907 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700908 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
909 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
910 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600911 }
912 }
913 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500914
Jeff Bolz9af91c52018-09-01 21:53:57 -0500915 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
916 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700917 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
918 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
919 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500920 }
921 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700922 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
923 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
924 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500925 }
926 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700927 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
928 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
929 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500930 }
931 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500932
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700933 if (image_flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600934 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700935 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
936 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
937 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500938 }
939
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700940 if ((image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(image_format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700941 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
942 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800943 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format (%s) must not be a "
944 "depth/stencil format.",
945 string_VkFormat(image_format));
Jeff Bolzef40fec2018-09-01 22:04:34 -0500946 }
947
Dave Houlton142c4cb2018-10-17 15:04:41 -0600948 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
950 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
951 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
952 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500953 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600954 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700955 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
956 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
957 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
958 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500959 }
960 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500961
sfricke-samsungf60b6c82021-04-05 22:59:20 -0700962 if (((image_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
sfricke-samsung61a57c02021-01-10 21:35:12 -0800963 (FormatHasDepth(image_format) == false)) {
sfricke-samsung8f658d42020-05-03 20:12:24 -0700964 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
965 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
sfricke-samsung61a57c02021-01-10 21:35:12 -0800966 "format (%s) must be a depth or depth/stencil format.",
967 string_VkFormat(image_format));
sfricke-samsung8f658d42020-05-03 20:12:24 -0700968 }
969
Mark Lobodzinski1f887d32020-12-30 15:31:33 -0700970 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500971 if (image_stencil_struct != nullptr) {
972 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
973 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
974 // No flags other than the legal attachment bits may be set
975 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
976 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700977 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
978 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
979 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
980 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500981 }
982 }
983
sfricke-samsung61a57c02021-01-10 21:35:12 -0800984 if (FormatIsDepthOrStencil(image_format)) {
Andrew Fobel3abeb992020-01-20 16:33:22 -0500985 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
986 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -0700987 skip |=
988 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
989 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
990 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
991 ") exceeds device "
992 "maxFramebufferWidth (%" PRIu32 ")",
993 pCreateInfo->extent.width, device_limits.maxFramebufferWidth);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500994 }
995
996 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -0700997 skip |=
998 LogError(device, "VUID-VkImageCreateInfo-format-02537",
999 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1000 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
1001 ") exceeds device "
1002 "maxFramebufferHeight (%" PRIu32 ")",
1003 pCreateInfo->extent.height, device_limits.maxFramebufferHeight);
Andrew Fobel3abeb992020-01-20 16:33:22 -05001004 }
1005 }
1006
1007 if (!physical_device_features.shaderStorageImageMultisample &&
1008 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1009 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1010 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001011 LogError(device, "VUID-VkImageCreateInfo-format-02538",
1012 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
1013 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
1014 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -05001015 }
1016
1017 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
1018 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001019 skip |= LogError(
1020 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001021 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1022 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1023 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1024 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
1025 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001026 skip |= LogError(
1027 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001028 "vkCreateImage(): Depth-stencil image in which usage does not include "
1029 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
1030 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1031 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
1032 }
1033
1034 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
1035 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001036 skip |= LogError(
1037 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001038 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1039 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1040 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1041 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
1042 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001043 skip |= LogError(
1044 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -05001045 "vkCreateImage(): Depth-stencil image in which usage does not include "
1046 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
1047 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
1048 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
1049 }
1050 }
1051 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -07001052
1053 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
1054 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
1055 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
1056 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
1057 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
1058 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001059
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001060 std::vector<uint64_t> image_create_drm_format_modifiers;
sfricke-samsung45996a42021-09-16 13:45:27 -07001061 if (IsExtEnabled(device_extensions.vk_ext_image_drm_format_modifier)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001062 const auto drm_format_mod_list = LvlFindInChain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
1063 const auto drm_format_mod_explict = LvlFindInChain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001064 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1065 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
1066 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
1067 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
1068 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
1069 "either VkImageDrmFormatModifierListCreateInfoEXT or "
1070 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
Martin Freebody0ec2c7a2021-03-03 16:48:00 +00001071 } else if (drm_format_mod_explict != nullptr) {
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001072 image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier);
1073 } else if (drm_format_mod_list != nullptr) {
1074 for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) {
1075 image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers);
1076 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -07001077 }
1078 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
1079 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
1080 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
1081 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
1082 "in the pNext chain");
1083 }
1084 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001085
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001086 static const uint64_t drm_format_mod_linear = 0;
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001087 bool image_create_maybe_linear = false;
1088 if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) {
1089 image_create_maybe_linear = true;
1090 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) {
1091 image_create_maybe_linear = false;
1092 } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1093 image_create_maybe_linear =
1094 (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(),
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001095 drm_format_mod_linear) != image_create_drm_format_modifiers.end());
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001096 }
1097
1098 // If multi-sample, validate type, usage, tiling and mip levels.
1099 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001100 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001101 (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) {
1102 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
1103 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
1104 }
1105
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001106 if ((image_flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) &&
Mark Lobodzinski09b4caa2020-11-20 17:26:46 -07001107 ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) ||
1108 image_create_maybe_linear)) {
1109 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259",
1110 "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips.");
1111 }
1112
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001113 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
1114 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1115 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
1116 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1117 "imageType must be VK_IMAGE_TYPE_2D.");
1118 }
1119 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1120 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
1121 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
1122 "samples must be VK_SAMPLE_COUNT_1_BIT.");
1123 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001124 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001125 if (image_flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001126 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1127 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
1128 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1129 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
1130 }
1131 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1132 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
1133 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1134 "imageType must be VK_IMAGE_TYPE_2D.");
1135 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001136 if (image_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001137 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
1138 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
1139 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1140 }
1141 if (pCreateInfo->mipLevels != 1) {
1142 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001143 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%" PRIu32
1144 ") must be 1.",
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02001145 pCreateInfo->mipLevels);
1146 }
1147 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001148
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001149 const auto swapchain_create_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001150 if (swapchain_create_info != nullptr) {
1151 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1152 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1153 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1154 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1155 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1156 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1157
1158 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1159 // also implicitly forces the check above that extent.depth is 1
1160 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1161 string_VkImageType(pCreateInfo->imageType));
1162 }
1163 if (pCreateInfo->mipLevels != 1) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001164 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %" PRIu32 ".", base_message,
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001165 pCreateInfo->mipLevels);
1166 }
1167 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1168 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1169 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1170 }
1171 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1172 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1173 base_message, string_VkImageTiling(pCreateInfo->tiling));
1174 }
1175 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1176 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1177 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1178 }
1179 const VkImageCreateFlags valid_flags =
1180 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001181 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001182 if ((image_flags & ~valid_flags) != 0) {
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001183 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001184 image_flags);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001185 }
1186 }
1187 }
sfricke-samsung61a57c02021-01-10 21:35:12 -08001188
1189 // If Chroma subsampled format ( _420_ or _422_ )
1190 if (FormatIsXChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.width, 2) != 0)) {
1191 skip |=
1192 LogError(device, "VUID-VkImageCreateInfo-format-04712",
1193 "vkCreateImage(): The format (%s) is X Chroma Subsampled (has _422 or _420 suffix) so the width (=%" PRIu32
1194 ") must be a multiple of 2.",
1195 string_VkFormat(image_format), pCreateInfo->extent.width);
1196 }
1197 if (FormatIsYChromaSubsampled(image_format) && (SafeModulo(pCreateInfo->extent.height, 2) != 0)) {
1198 skip |= LogError(device, "VUID-VkImageCreateInfo-format-04713",
1199 "vkCreateImage(): The format (%s) is Y Chroma Subsampled (has _420 suffix) so the height (=%" PRIu32
1200 ") must be a multiple of 2.",
1201 string_VkFormat(image_format), pCreateInfo->extent.height);
1202 }
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001203
1204 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
1205 if (format_list_info) {
1206 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
1207 if (((image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) == 0) && (viewFormatCount > 1)) {
1208 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-04738",
1209 "vkCreateImage(): If the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001210 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32 ") must be 0 or 1.",
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001211 viewFormatCount);
1212 }
1213 // Check if viewFormatCount is not zero that it is all compatible
1214 for (uint32_t i = 0; i < viewFormatCount; i++) {
1215 if (FormatCompatibilityClass(format_list_info->pViewFormats[i]) != FormatCompatibilityClass(image_format)) {
1216 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-04737",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001217 "vkCreateImage(): VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
1218 "] (%s) and "
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001219 "VkImageCreateInfo::format (%s) are not compatible.",
Esther O'Keefed37c24b2021-09-27 12:45:40 +10001220 i, string_VkFormat(format_list_info->pViewFormats[i]), string_VkFormat(image_format));
sfricke-samsungf60b6c82021-04-05 22:59:20 -07001221 }
1222 }
1223 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001224 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001225
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001226 return skip;
1227}
1228
Jeff Bolz99e3f632020-03-24 22:59:22 -05001229bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1230 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1231 bool skip = false;
1232
1233 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001234 // Validate feature set if using CUBE_ARRAY
1235 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1236 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1237 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1238 "enabling the imageCubeArray feature.");
1239 }
1240
Jeff Bolz99e3f632020-03-24 22:59:22 -05001241 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1242 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1243 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001244 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1245 ") must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001246 pCreateInfo->subresourceRange.layerCount);
1247 }
1248 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001249 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02961",
1250 "vkCreateImageView(): subresourceRange.layerCount (%" PRIu32
1251 ") must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1252 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001253 }
1254 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001255
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001256 auto astc_decode_mode = LvlFindInChain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
sfricke-samsung45996a42021-09-16 13:45:27 -07001257 if (IsExtEnabled(device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001258 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1259 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1260 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1261 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1262 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1263 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1264 }
sfricke-samsunge3086292021-11-18 23:02:35 -08001265 if ((FormatIsCompressed_ASTC_LDR(pCreateInfo->format) == false) &&
1266 (FormatIsCompressed_ASTC_HDR(pCreateInfo->format) == false)) {
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001267 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1268 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1269 "not an ASTC format.",
1270 string_VkFormat(pCreateInfo->format));
1271 }
1272 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001273
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07001274 auto ycbcr_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
sfricke-samsung83d98122020-07-04 06:21:15 -07001275 if (ycbcr_conversion != nullptr) {
1276 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1277 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1278 skip |= LogError(
1279 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1280 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1281 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1282 "r swizzle = %s\n"
1283 "g swizzle = %s\n"
1284 "b swizzle = %s\n"
1285 "a swizzle = %s\n",
1286 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1287 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1288 }
1289 }
1290 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001291 }
1292 return skip;
1293}
1294
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001295bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001297 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001298
1299 // Note: for numerical correctness
1300 // - float comparisons should expect NaN (comparison always false).
1301 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1302
1303 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001304 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001305 if (v1_f <= 0.0f) return true;
1306
1307 float intpart;
1308 const float fract = modff(v1_f, &intpart);
1309
1310 assert(std::numeric_limits<float>::radix == 2);
1311 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1312 if (intpart >= u32_max_plus1) return false;
1313
1314 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001315 if (v1_u32 < v2_u32) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001316 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001317 } else if (v1_u32 == v2_u32 && fract == 0.0f) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001318 return true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001319 } else {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001320 return false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001321 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01001322 };
1323
1324 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1325 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1326 return (v1_f <= v2_f);
1327 };
1328
1329 // width
1330 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001331 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001332
1333 if (!(viewport.width > 0.0f)) {
1334 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001335 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1336 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001337 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1338 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001339 skip |= LogError(object, "VUID-VkViewport-width-01771",
1340 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1341 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001342 }
1343
1344 // height
1345 bool height_healthy = true;
sfricke-samsung45996a42021-09-16 13:45:27 -07001346 const bool negative_height_enabled =
1347 IsExtEnabled(device_extensions.vk_khr_maintenance1) || IsExtEnabled(device_extensions.vk_amd_negative_viewport_height);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001348 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001349
1350 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1351 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001352 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1353 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001354 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1355 height_healthy = false;
1356
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001357 skip |= LogError(object, "VUID-VkViewport-height-01773",
1358 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1359 ").",
1360 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001361 }
1362
1363 // x
1364 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001365 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001366 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001367 skip |= LogError(object, "VUID-VkViewport-x-01774",
1368 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1369 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001370 }
1371
1372 // x + width
1373 if (x_healthy && width_healthy) {
1374 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001375 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001376 skip |= LogError(
1377 object, "VUID-VkViewport-x-01232",
1378 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1379 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1380 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001381 }
1382 }
1383
1384 // y
1385 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001386 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001387 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001388 skip |= LogError(object, "VUID-VkViewport-y-01775",
1389 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1390 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001391 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001392 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001393 skip |= LogError(object, "VUID-VkViewport-y-01776",
1394 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1395 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001396 }
1397
1398 // y + height
1399 if (y_healthy && height_healthy) {
1400 const float boundary = viewport.y + viewport.height;
1401
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001402 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001403 skip |= LogError(object, "VUID-VkViewport-y-01233",
1404 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1405 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1406 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001407 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001408 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001409 LogError(object, "VUID-VkViewport-y-01777",
1410 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1411 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1412 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001413 }
1414 }
1415
sfricke-samsungfd06d422021-01-22 02:17:21 -08001416 // 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 -07001417 if (!IsExtEnabled(device_extensions.vk_ext_depth_range_unrestricted)) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001418 // minDepth
1419 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001420 // Also VUID-VkViewport-minDepth-02540
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001421 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001422 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1423 "[0.0, 1.0] range.",
1424 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001425 }
1426
1427 // maxDepth
1428 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
sfricke-samsungfd06d422021-01-22 02:17:21 -08001429 // Also VUID-VkViewport-maxDepth-02541
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001430 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001431 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1432 "[0.0, 1.0] range.",
1433 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001434 }
1435 }
1436
1437 return skip;
1438}
1439
Dave Houlton142c4cb2018-10-17 15:04:41 -06001440struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001441 VkShadingRatePaletteEntryNV shadingRate;
1442 uint32_t width;
1443 uint32_t height;
1444};
1445
1446// All palette entries with more than one pixel per fragment
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001447static SampleOrderInfo sample_order_infos[] = {
Dave Houlton142c4cb2018-10-17 15:04:41 -06001448 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1449 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1450 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1451 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1452 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1453 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001454};
1455
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001456bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001457 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001458
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001459 SampleOrderInfo *sample_order_info;
1460 uint32_t info_idx = 0;
1461 for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) {
1462 if (sample_order_infos[info_idx].shadingRate == order->shadingRate) {
1463 sample_order_info = &sample_order_infos[info_idx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001464 break;
1465 }
1466 }
1467
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001468 if (sample_order_info == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001469 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1470 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1471 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001472 return skip;
1473 }
1474
Dave Houlton142c4cb2018-10-17 15:04:41 -06001475 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001476 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001477 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1478 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1479 ") must "
1480 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1481 "is set in framebufferNoAttachmentsSampleCounts.",
1482 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001483 }
1484
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001485 if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001486 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1487 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1488 ") must "
1489 "be equal to the product of sampleCount (=%" PRIu32
1490 "), the fragment width for shadingRate "
1491 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001492 order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001493 }
1494
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001495 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001496 skip |= LogError(
1497 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001498 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1499 ") must "
1500 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001501 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001502 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001503
1504 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001505 // the first width*height*sampleCount bits to all be set. Note: There is no
1506 // guarantee that 64 bits is enough, but practically it's unlikely for an
1507 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001508 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001509 uint64_t sample_locations_mask = 0;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001510 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001511 const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i];
1512 if (sample_loc->pixelX >= sample_order_info->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1514 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001515 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001516 if (sample_loc->pixelY >= sample_order_info->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001517 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1518 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001519 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001520 if (sample_loc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001521 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1522 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001523 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001524 uint32_t idx =
1525 sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY);
1526 sample_locations_mask |= 1ULL << idx;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001527 }
1528
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07001529 uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1530 if (sample_locations_mask != expected_mask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001531 skip |= LogError(
1532 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001533 "The array pSampleLocations must contain exactly one entry for "
1534 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001535 }
1536
1537 return skip;
1538}
1539
sfricke-samsung51303fb2021-05-09 19:09:13 -07001540bool StatelessValidation::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
1541 const VkAllocationCallbacks *pAllocator,
1542 VkPipelineLayout *pPipelineLayout) const {
1543 bool skip = false;
1544 // Validate layout count against device physical limit
1545 if (pCreateInfo->setLayoutCount > device_limits.maxBoundDescriptorSets) {
1546 skip |= LogError(device, "VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001547 "vkCreatePipelineLayout(): setLayoutCount (%" PRIu32
1548 ") exceeds physical device maxBoundDescriptorSets limit (%" PRIu32 ").",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001549 pCreateInfo->setLayoutCount, device_limits.maxBoundDescriptorSets);
1550 }
1551
1552 // Validate Push Constant ranges
1553 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1554 const uint32_t offset = pCreateInfo->pPushConstantRanges[i].offset;
1555 const uint32_t size = pCreateInfo->pPushConstantRanges[i].size;
1556 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
1557 // Check that offset + size don't exceed the max.
1558 // Prevent arithetic overflow here by avoiding addition and testing in this order.
1559 if (offset >= max_push_constants_size) {
1560 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00294",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001561 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1562 ") that exceeds this "
1563 "device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001564 i, offset, max_push_constants_size);
1565 }
1566 if (size > max_push_constants_size - offset) {
1567 skip |= LogError(device, "VUID-VkPushConstantRange-size-00298",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001568 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "] offset (%" PRIu32
1569 ") and size (%" PRIu32
1570 ") "
1571 "together exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001572 i, offset, size, max_push_constants_size);
1573 }
1574
1575 // size needs to be non-zero and a multiple of 4.
1576 if (size == 0) {
1577 skip |= LogError(device, "VUID-VkPushConstantRange-size-00296",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001578 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1579 ") is not greater than zero.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001580 i, size);
1581 }
1582 if (size & 0x3) {
1583 skip |= LogError(device, "VUID-VkPushConstantRange-size-00297",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001584 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].size (%" PRIu32
1585 ") is not a multiple of 4.",
1586 i, size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001587 }
1588
1589 // offset needs to be a multiple of 4.
1590 if ((offset & 0x3) != 0) {
1591 skip |= LogError(device, "VUID-VkPushConstantRange-offset-00295",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001592 "vkCreatePipelineLayout(): pCreateInfo->pPushConstantRanges[%" PRIu32 "].offset (%" PRIu32
1593 ") is not a multiple of 4.",
sfricke-samsung51303fb2021-05-09 19:09:13 -07001594 i, offset);
1595 }
1596 }
1597
1598 // 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.
1599 for (uint32_t i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
1600 for (uint32_t j = i + 1; j < pCreateInfo->pushConstantRangeCount; ++j) {
1601 if (0 != (pCreateInfo->pPushConstantRanges[i].stageFlags & pCreateInfo->pPushConstantRanges[j].stageFlags)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001602 skip |=
1603 LogError(device, "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292",
1604 "vkCreatePipelineLayout() Duplicate stage flags found in ranges %" PRIu32 " and %" PRIu32 ".", i, j);
sfricke-samsung51303fb2021-05-09 19:09:13 -07001605 }
1606 }
1607 }
1608 return skip;
1609}
1610
ziga-lunargc6341372021-07-28 12:57:42 +02001611bool StatelessValidation::ValidatePipelineShaderStageCreateInfo(const char *func_name, const char *msg,
1612 const VkPipelineShaderStageCreateInfo *pCreateInfo) const {
1613 bool skip = false;
1614
1615 const auto *required_subgroup_size_features =
1616 LvlFindInChain<VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(pCreateInfo->pNext);
1617
1618 if (required_subgroup_size_features) {
1619 if ((pCreateInfo->flags & VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT) != 0) {
1620 skip |= LogError(
1621 device, "VUID-VkPipelineShaderStageCreateInfo-pNext-02754",
1622 "%s(): %s->flags (0x%x) includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT while "
1623 "VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT is included in the pNext chain.",
1624 func_name, msg, pCreateInfo->flags);
1625 }
1626 }
1627
1628 return skip;
1629}
1630
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001631bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1632 uint32_t createInfoCount,
1633 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1634 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001635 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001636 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001637
1638 if (pCreateInfos != nullptr) {
1639 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001640 bool has_dynamic_viewport = false;
1641 bool has_dynamic_scissor = false;
1642 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001643 bool has_dynamic_depth_bias = false;
1644 bool has_dynamic_blend_constant = false;
1645 bool has_dynamic_depth_bounds = false;
1646 bool has_dynamic_stencil_compare = false;
1647 bool has_dynamic_stencil_write = false;
1648 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001649 bool has_dynamic_viewport_w_scaling_nv = false;
1650 bool has_dynamic_discard_rectangle_ext = false;
1651 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001652 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001653 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001654 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001655 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001656 bool has_dynamic_cull_mode = false;
1657 bool has_dynamic_front_face = false;
1658 bool has_dynamic_primitive_topology = false;
1659 bool has_dynamic_viewport_with_count = false;
1660 bool has_dynamic_scissor_with_count = false;
1661 bool has_dynamic_vertex_input_binding_stride = false;
1662 bool has_dynamic_depth_test_enable = false;
1663 bool has_dynamic_depth_write_enable = false;
1664 bool has_dynamic_depth_compare_op = false;
1665 bool has_dynamic_depth_bounds_test_enable = false;
1666 bool has_dynamic_stencil_test_enable = false;
1667 bool has_dynamic_stencil_op = false;
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001668 bool has_patch_control_points = false;
1669 bool has_rasterizer_discard_enable = false;
1670 bool has_depth_bias_enable = false;
1671 bool has_logic_op = false;
1672 bool has_primitive_restart_enable = false;
Piers Daniellcb6d8032021-04-19 18:51:26 -06001673 bool has_dynamic_vertex_input = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001674 if (pCreateInfos[i].pDynamicState != nullptr) {
1675 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1676 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1677 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001678 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1679 if (has_dynamic_viewport == true) {
1680 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1681 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001682 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001683 i);
1684 }
1685 has_dynamic_viewport = true;
1686 }
1687 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1688 if (has_dynamic_scissor == true) {
1689 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1690 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001691 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001692 i);
1693 }
1694 has_dynamic_scissor = true;
1695 }
1696 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1697 if (has_dynamic_line_width == true) {
1698 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1699 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001700 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001701 i);
1702 }
1703 has_dynamic_line_width = true;
1704 }
1705 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1706 if (has_dynamic_depth_bias == true) {
1707 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1708 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001709 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001710 i);
1711 }
1712 has_dynamic_depth_bias = true;
1713 }
1714 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1715 if (has_dynamic_blend_constant == true) {
1716 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1717 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001718 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001719 i);
1720 }
1721 has_dynamic_blend_constant = true;
1722 }
1723 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1724 if (has_dynamic_depth_bounds == true) {
1725 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1726 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001727 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001728 i);
1729 }
1730 has_dynamic_depth_bounds = true;
1731 }
1732 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1733 if (has_dynamic_stencil_compare == true) {
1734 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1735 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001736 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001737 i);
1738 }
1739 has_dynamic_stencil_compare = true;
1740 }
1741 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1742 if (has_dynamic_stencil_write == true) {
1743 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1744 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001745 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001746 i);
1747 }
1748 has_dynamic_stencil_write = true;
1749 }
1750 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1751 if (has_dynamic_stencil_reference == true) {
1752 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1753 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001754 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001755 i);
1756 }
1757 has_dynamic_stencil_reference = true;
1758 }
1759 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1760 if (has_dynamic_viewport_w_scaling_nv == true) {
1761 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1762 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001763 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001764 i);
1765 }
1766 has_dynamic_viewport_w_scaling_nv = true;
1767 }
1768 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1769 if (has_dynamic_discard_rectangle_ext == true) {
1770 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1771 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001772 "in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001773 i);
1774 }
1775 has_dynamic_discard_rectangle_ext = true;
1776 }
1777 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1778 if (has_dynamic_sample_locations_ext == true) {
1779 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1780 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001781 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001782 i);
1783 }
1784 has_dynamic_sample_locations_ext = true;
1785 }
1786 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1787 if (has_dynamic_exclusive_scissor_nv == true) {
1788 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1789 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001790 "the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001791 i);
1792 }
1793 has_dynamic_exclusive_scissor_nv = true;
1794 }
1795 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1796 if (has_dynamic_shading_rate_palette_nv == true) {
1797 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1798 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001799 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001800 i);
1801 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001802 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001803 }
1804 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1805 if (has_dynamic_viewport_course_sample_order_nv == true) {
1806 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1807 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001808 "listed twice in the pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001809 i);
1810 }
1811 has_dynamic_viewport_course_sample_order_nv = true;
1812 }
1813 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1814 if (has_dynamic_line_stipple == true) {
1815 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1816 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001817 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Spencer Fricke8d428882020-03-16 17:23:33 -07001818 i);
1819 }
1820 has_dynamic_line_stipple = true;
1821 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001822 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1823 if (has_dynamic_cull_mode) {
1824 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1825 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001826 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001827 i);
1828 }
1829 has_dynamic_cull_mode = true;
1830 }
1831 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1832 if (has_dynamic_front_face) {
1833 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1834 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001835 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001836 i);
1837 }
1838 has_dynamic_front_face = true;
1839 }
1840 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1841 if (has_dynamic_primitive_topology) {
1842 skip |= LogError(
1843 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1844 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001845 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001846 i);
1847 }
1848 has_dynamic_primitive_topology = true;
1849 }
1850 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1851 if (has_dynamic_viewport_with_count) {
1852 skip |= LogError(
1853 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1854 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001855 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001856 i);
1857 }
1858 has_dynamic_viewport_with_count = true;
1859 }
1860 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1861 if (has_dynamic_scissor_with_count) {
1862 skip |= LogError(
1863 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1864 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001865 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001866 i);
1867 }
1868 has_dynamic_scissor_with_count = true;
1869 }
1870 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1871 if (has_dynamic_vertex_input_binding_stride) {
1872 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1873 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1874 "listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001875 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001876 i);
1877 }
1878 has_dynamic_vertex_input_binding_stride = true;
1879 }
1880 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1881 if (has_dynamic_depth_test_enable) {
1882 skip |= LogError(
1883 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1884 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001885 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001886 i);
1887 }
1888 has_dynamic_depth_test_enable = true;
1889 }
1890 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1891 if (has_dynamic_depth_write_enable) {
1892 skip |= LogError(
1893 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1894 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001895 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001896 i);
1897 }
1898 has_dynamic_depth_write_enable = true;
1899 }
1900 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1901 if (has_dynamic_depth_compare_op) {
1902 skip |=
1903 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1904 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001905 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001906 i);
1907 }
1908 has_dynamic_depth_compare_op = true;
1909 }
1910 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1911 if (has_dynamic_depth_bounds_test_enable) {
1912 skip |= LogError(
1913 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1914 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001915 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001916 i);
1917 }
1918 has_dynamic_depth_bounds_test_enable = true;
1919 }
1920 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1921 if (has_dynamic_stencil_test_enable) {
1922 skip |= LogError(
1923 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1924 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001925 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001926 i);
1927 }
1928 has_dynamic_stencil_test_enable = true;
1929 }
1930 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1931 if (has_dynamic_stencil_op) {
1932 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1933 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001934 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Piers Daniell39842ee2020-07-10 16:42:33 -06001935 i);
1936 }
1937 has_dynamic_stencil_op = true;
1938 }
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001939 if (dynamic_state == VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
1940 // Not allowed for graphics pipelines
1941 skip |= LogError(
1942 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03578",
1943 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR was listed the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001944 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates[%" PRIu32
1945 "] but not allowed in graphic pipelines.",
sfricke-samsung5f8f9702021-01-29 23:30:30 -08001946 i, state_index);
1947 }
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001948 if (dynamic_state == VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT) {
1949 if (has_patch_control_points) {
1950 skip |= LogError(
1951 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1952 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001953 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001954 i);
1955 }
1956 has_patch_control_points = true;
1957 }
1958 if (dynamic_state == VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT) {
1959 if (has_rasterizer_discard_enable) {
1960 skip |= LogError(
1961 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1962 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001963 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001964 i);
1965 }
1966 has_rasterizer_discard_enable = true;
1967 }
1968 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT) {
1969 if (has_depth_bias_enable) {
1970 skip |= LogError(
1971 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1972 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001973 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001974 i);
1975 }
1976 has_depth_bias_enable = true;
1977 }
1978 if (dynamic_state == VK_DYNAMIC_STATE_LOGIC_OP_EXT) {
1979 if (has_logic_op) {
1980 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1981 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LOGIC_OP_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001982 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001983 i);
1984 }
1985 has_logic_op = true;
1986 }
1987 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT) {
1988 if (has_primitive_restart_enable) {
1989 skip |= LogError(
1990 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1991 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT was listed twice in the "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07001992 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
Vikram Kushwahaa57b0c32021-04-19 12:21:46 -07001993 i);
1994 }
1995 has_primitive_restart_enable = true;
1996 }
Piers Daniellcb6d8032021-04-19 18:51:26 -06001997 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_EXT) {
1998 if (has_dynamic_vertex_input) {
1999 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002000 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_EXT was listed twice in the "
2001 "pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
2002 i);
Piers Daniellcb6d8032021-04-19 18:51:26 -06002003 }
2004 has_dynamic_vertex_input = true;
2005 }
Petr Kraus299ba622017-11-24 03:09:03 +01002006 }
2007 }
2008
sfricke-samsung3b944422021-01-23 02:15:19 -08002009 if (has_dynamic_viewport_with_count && has_dynamic_viewport) {
2010 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132",
2011 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002012 "VK_DYNAMIC_STATE_VIEWPORT both listed in pCreateInfos[%" PRIu32
2013 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002014 i);
2015 }
2016
2017 if (has_dynamic_scissor_with_count && has_dynamic_scissor) {
2018 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133",
2019 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT and VK_DYNAMIC_STATE_SCISSOR "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002020 "both listed in pCreateInfos[%" PRIu32 "].pDynamicState->pDynamicStates array",
sfricke-samsung3b944422021-01-23 02:15:19 -08002021 i);
2022 }
2023
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002024 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04002025 if ((feedback_struct != nullptr) &&
2026 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002027 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
2028 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
2029 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
2030 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
2031 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04002032 }
2033
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002034 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002035
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002036 // Collect active stages and other information
2037 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002038 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002039 bool has_eval = false;
2040 bool has_control = false;
2041 if (pCreateInfos[i].pStages != nullptr) {
2042 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
2043 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
2044
2045 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
2046 has_control = true;
2047 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
2048 has_eval = true;
2049 }
2050
2051 skip |= validate_string(
2052 "vkCreateGraphicsPipelines",
2053 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
2054 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
ziga-lunargc6341372021-07-28 12:57:42 +02002055
2056 std::stringstream msg;
2057 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
2058 ValidatePipelineShaderStageCreateInfo("vkCreateGraphicsPipelines", msg.str().c_str(),
2059 &pCreateInfos[i].pStages[stage_index]);
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002060 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002061 }
2062
2063 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
2064 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
2065 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
2066 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
2067 pCreateInfos[i].pTessellationState,
2068 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
2069 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
2070
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002071 const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002072 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
2073
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002074 skip |= validate_struct_pnext(
2075 "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
2076 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext,
2077 ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info),
2078 allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion,
2079 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
2080 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002081
2082 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
2083 pCreateInfos[i].pTessellationState->flags,
2084 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
2085 }
2086
2087 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
2088 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
2089 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
2090 pCreateInfos[i].pInputAssemblyState,
2091 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
2092 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
2093
2094 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
2095 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002096 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002097
2098 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
2099 pCreateInfos[i].pInputAssemblyState->flags,
2100 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
2101
2102 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
2103 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
2104 pCreateInfos[i].pInputAssemblyState->topology,
2105 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
2106
2107 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
2108 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
2109 }
2110
2111 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002112 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02002113
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002114 if (pCreateInfos[i].pVertexInputState->flags != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002115 skip |=
2116 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
2117 "vkCreateGraphicsPipelines: pararameter "
2118 "pCreateInfos[%" PRIu32 "].pVertexInputState->flags (%" PRIu32 ") is reserved and must be zero.",
2119 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002120 }
2121
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002122 const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002123 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
2124 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
2125 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
2126 pCreateInfos[i].pVertexInputState->pNext, 1,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002127 allowed_structs_vk_pipeline_vertex_input_state_create_info,
2128 GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002129 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002130 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
2131 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06002132 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002133 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
2134 skip |=
2135 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
2136 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
2137 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
2138 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
2139 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
2140
2141 skip |= validate_array(
2142 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
2143 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
2144 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
2145 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
2146
2147 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002148 for (uint32_t vertex_binding_description_index = 0;
2149 vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
2150 ++vertex_binding_description_index) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002151 skip |= validate_ranged_enum(
2152 "vkCreateGraphicsPipelines",
2153 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
2154 AllVkVertexInputRateEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002155 pCreateInfos[i]
2156 .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index]
2157 .inputRate,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002158 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
2159 }
2160 }
2161
2162 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002163 for (uint32_t vertex_attribute_description_index = 0;
2164 vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
2165 ++vertex_attribute_description_index) {
sfricke-samsung2e827212021-09-28 07:52:08 -07002166 const VkFormat format =
2167 pCreateInfos[i]
2168 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2169 .format;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002170 skip |= validate_ranged_enum(
2171 "vkCreateGraphicsPipelines",
2172 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
2173 AllVkFormatEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002174 pCreateInfos[i]
2175 .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index]
2176 .format,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002177 "VUID-VkVertexInputAttributeDescription-format-parameter");
sfricke-samsung2e827212021-09-28 07:52:08 -07002178 if (FormatIsDepthOrStencil(format)) {
2179 // Should never hopefully get here, but there are known driver advertising the wrong feature flags
2180 // see https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/4849
2181 skip |= LogError(device, kVUID_Core_invalidDepthStencilFormat,
2182 "vkCreateGraphicsPipelines: "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002183 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2184 "].format is a "
sfricke-samsung2e827212021-09-28 07:52:08 -07002185 "depth/stencil format (%s) but depth/stencil formats do not have a defined sizes for "
2186 "alignment, replace with a color format.",
2187 i, vertex_attribute_description_index, string_VkFormat(format));
2188 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002189 }
2190 }
2191
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002192 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002193 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
2194 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002195 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexBindingDescriptionCount (%" PRIu32
2196 ") is "
2197 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002199 }
2200
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002201 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 skip |=
2203 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
2204 "vkCreateGraphicsPipelines: pararameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002205 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptionCount (%" PRIu32
2206 ") is "
2207 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002208 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002209 }
2210
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002211 layer_data::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002212 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
2213 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002214 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
2215 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002216 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
2217 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002218 "pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription[%" PRIu32
2219 "].binding "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002220 "(%" PRIu32 ") is not distinct.",
2221 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002222 }
2223 vertex_bindings.insert(vertex_bind_desc.binding);
2224
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002225 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002226 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
2227 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002228 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2229 "].binding (%" PRIu32
2230 ") is "
2231 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002232 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002233 }
2234
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002235 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002236 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
2237 "vkCreateGraphicsPipelines: parameter "
2238 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexBindingDescriptions[%" PRIu32
2239 "].stride (%" PRIu32
2240 ") is greater "
2241 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%" PRIu32 ").",
2242 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002243 }
2244 }
2245
Jeremy Gebbencbf22862021-03-03 12:01:22 -07002246 layer_data::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002247 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
2248 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02002249 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
2250 if (location_it != attribute_locations.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002251 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
2252 "vkCreateGraphicsPipelines: parameter "
2253 "pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2254 "].location (%" PRIu32 ") is not distinct.",
2255 i, d, vertex_attrib_desc.location);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002256 }
2257 attribute_locations.insert(vertex_attrib_desc.location);
2258
2259 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
2260 if (binding_it == vertex_bindings.cend()) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002261 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
2262 "vkCreateGraphicsPipelines: parameter "
2263 " pCreateInfo[%" PRIu32 "].pVertexInputState->vertexAttributeDescriptions[%" PRIu32
2264 "].binding (%" PRIu32
2265 ") does not exist "
2266 "in any pCreateInfo[%" PRIu32 "].pVertexInputState->pVertexBindingDescription.",
2267 i, d, vertex_attrib_desc.binding, i);
Peter Kohautc7d9d392018-07-15 00:34:07 +02002268 }
2269
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002270 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002271 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
2272 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002273 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2274 "].location (%" PRIu32
2275 ") is "
2276 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002277 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002278 }
2279
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002280 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002281 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
2282 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002283 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2284 "].binding (%" PRIu32
2285 ") is "
2286 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002287 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002288 }
2289
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002290 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002291 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
2292 "vkCreateGraphicsPipelines: parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002293 "pCreateInfos[%" PRIu32 "].pVertexInputState->pVertexAttributeDescriptions[%" PRIu32
2294 "].offset (%" PRIu32
2295 ") is "
2296 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%" PRIu32 ").",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002297 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298 }
2299 }
2300 }
2301
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002302 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
2303 if (has_control && has_eval) {
2304 if (pCreateInfos[i].pTessellationState == nullptr) {
2305 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002306 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2307 "].pStages includes a tessellation control "
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002308 "shader stage and a tessellation evaluation shader stage, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002309 "pCreateInfos[%" PRIu32 "].pTessellationState must not be NULL.",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002310 i, i);
2311 } else {
2312 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
2313 skip |= validate_struct_pnext(
2314 "vkCreateGraphicsPipelines",
2315 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
2316 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
2317 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
2318 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002319
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002320 skip |= validate_reserved_flags(
2321 "vkCreateGraphicsPipelines",
2322 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
2323 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002324
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002325 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
2326 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
2327 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
2328 "vkCreateGraphicsPipelines: invalid parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002329 "pCreateInfos[%" PRIu32 "].pTessellationState->patchControlPoints value %" PRIu32
2330 ". patchControlPoints "
2331 "should be >0 and <=%" PRIu32 ".",
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07002332 i, pCreateInfos[i].pTessellationState->patchControlPoints,
2333 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002334 }
2335 }
2336 }
2337
2338 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
2339 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
2340 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
2341 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002342 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
2343 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
2344 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
2345 "].pViewportState (=NULL) is not a valid pointer.",
2346 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002347 } else {
Petr Krausa6103552017-11-16 21:21:58 +01002348 const auto &viewport_state = *pCreateInfos[i].pViewportState;
2349
2350 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002351 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
2352 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2353 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
2354 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002355 }
2356
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002357 const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = {
Petr Krausa6103552017-11-16 21:21:58 +01002358 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002359 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
2360 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05002361 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
2362 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002363 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002364 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002365 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002366 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002367 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002368 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002369 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002370 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV, VkPipelineViewportDepthClipControlCreateInfoEXT",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002371 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002372 allowed_structs_vk_pipeline_viewport_state_create_info, 200,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002373 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002374 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002375
2376 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002377 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002378 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002379 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002380
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002381 auto exclusive_scissor_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002382 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002383 auto shading_rate_image_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002384 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(viewport_state.pNext);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002385 auto coarse_sample_order_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002386 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(viewport_state.pNext);
2387 const auto vp_swizzle_struct = LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(viewport_state.pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002388 const auto vp_w_scaling_struct =
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002389 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(viewport_state.pNext);
2390 const auto depth_clip_control_struct =
2391 LvlFindInChain<VkPipelineViewportDepthClipControlCreateInfoEXT>(viewport_state.pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002392
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002393 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002394 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002395 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2396 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2397 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2398 ") is not 1.",
2399 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002400 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002401
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002402 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002403 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2404 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2405 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2406 ") is not 1.",
2407 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002408 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002409
Dave Houlton142c4cb2018-10-17 15:04:41 -06002410 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2411 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002412 skip |= LogError(
2413 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2414 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2415 "disabled, but pCreateInfos[%" PRIu32
2416 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2417 ") is not 1.",
2418 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002419 }
2420
Jeff Bolz9af91c52018-09-01 21:53:57 -05002421 if (shading_rate_image_struct &&
2422 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002423 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2424 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2425 "disabled, but pCreateInfos[%" PRIu32
2426 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2427 ") is neither 0 nor 1.",
2428 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002429 }
2430
Petr Krausa6103552017-11-16 21:21:58 +01002431 } else { // multiViewport enabled
2432 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002433 if (!has_dynamic_viewport_with_count) {
2434 skip |= LogError(
2435 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2436 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2437 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002438 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2440 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2441 "].pViewportState->viewportCount (=%" PRIu32
2442 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2443 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002444 } else if (has_dynamic_viewport_with_count) {
2445 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2446 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2447 "].pViewportState->viewportCount (=%" PRIu32
2448 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2449 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450 }
Petr Krausa6103552017-11-16 21:21:58 +01002451
2452 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002453 if (!has_dynamic_scissor_with_count) {
2454 skip |= LogError(
2455 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2456 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2457 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002458 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002459 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2460 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2461 "].pViewportState->scissorCount (=%" PRIu32
2462 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2463 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002464 } else if (has_dynamic_scissor_with_count) {
2465 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2466 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2467 "].pViewportState->scissorCount (=%" PRIu32
2468 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2469 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002470 }
2471 }
2472
ziga-lunarg845883b2021-07-14 15:05:00 +02002473 if (!has_dynamic_scissor && viewport_state.pScissors) {
2474 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2475 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002476
2477 if (scissor.offset.x < 0) {
2478 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2479 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2480 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2481 scissor.offset.x, i, scissor_i);
2482 }
2483
2484 if (scissor.offset.y < 0) {
2485 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2486 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2487 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2488 scissor.offset.y, i, scissor_i);
2489 }
2490
ziga-lunarg845883b2021-07-14 15:05:00 +02002491 const int64_t x_sum =
2492 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2493 if (x_sum > std::numeric_limits<int32_t>::max()) {
2494 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2495 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2496 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2497 "] will overflow int32_t.",
2498 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2499 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002500
ziga-lunarg845883b2021-07-14 15:05:00 +02002501 const int64_t y_sum =
2502 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2503 if (y_sum > std::numeric_limits<int32_t>::max()) {
2504 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2505 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2506 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2507 "] will overflow int32_t.",
2508 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2509 }
2510 }
2511 }
2512
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002513 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002514 skip |=
2515 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2516 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2517 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2518 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002519 }
2520
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002521 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2523 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2524 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2525 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2526 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002527 }
2528
Piers Daniell39842ee2020-07-10 16:42:33 -06002529 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2530 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002531 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2532 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2533 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2534 "].pViewportState->viewportCount (=%" PRIu32 ").",
2535 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002536 }
2537
Dave Houlton142c4cb2018-10-17 15:04:41 -06002538 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002539 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002540 skip |=
2541 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2542 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2543 ") must be zero or identical to pCreateInfos[%" PRIu32
2544 "].pViewportState->viewportCount (=%" PRIu32 ").",
2545 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002546 }
2547
Dave Houlton142c4cb2018-10-17 15:04:41 -06002548 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002549 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002550 skip |= LogError(
2551 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002552 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2553 "] "
2554 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2555 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2556 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002557 }
2558
Petr Krausa6103552017-11-16 21:21:58 +01002559 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002560 skip |= LogError(
2561 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002562 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2563 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002564 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2565 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002566 }
2567
2568 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002569 skip |= LogError(
2570 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002571 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2572 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002573 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2574 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002575 }
2576
Jeff Bolz3e71f782018-08-29 23:15:45 -05002577 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002578 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2579 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2580 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002581 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002582 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2583 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2584 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2585 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002586 }
2587
Jeff Bolz9af91c52018-09-01 21:53:57 -05002588 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002589 shading_rate_image_struct->viewportCount > 0 &&
2590 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002591 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002592 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002593 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002594 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2595 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002596 i, i);
2597 }
2598
Chris Mayer328d8212018-12-11 14:16:18 +01002599 if (vp_swizzle_struct) {
2600 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002601 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2602 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2603 " does "
2604 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2605 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002606 }
2607 }
2608
Petr Krausb3fcdb42018-01-09 22:09:09 +01002609 // validate the VkViewports
2610 if (!has_dynamic_viewport && viewport_state.pViewports) {
2611 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2612 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002613 const char *fn_name = "vkCreateGraphicsPipelines";
2614 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2615 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2616 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002617 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002618 }
2619 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002620
sfricke-samsung45996a42021-09-16 13:45:27 -07002621 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002622 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2623 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2624 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2625 "VK_NV_clip_space_w_scaling extension is not enabled.",
2626 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002627 }
2628
sfricke-samsung45996a42021-09-16 13:45:27 -07002629 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
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_DISCARD_RECTANGLE_EXT, but "
2633 "VK_EXT_discard_rectangles 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_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
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_SAMPLE_LOCATIONS_EXT, but "
2641 "VK_EXT_sample_locations extension is not enabled.",
2642 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002643 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002644
sfricke-samsung45996a42021-09-16 13:45:27 -07002645 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
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_EXCLUSIVE_SCISSOR_NV, but "
2649 "VK_NV_scissor_exclusive extension is not enabled.",
2650 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002651 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002652
2653 if (coarse_sample_order_struct &&
2654 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2655 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002656 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2657 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2658 "] "
2659 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2660 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2661 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002662 }
2663
2664 if (coarse_sample_order_struct) {
2665 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002666 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002667 }
2668 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002669
2670 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2671 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002672 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2673 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2674 "] "
2675 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2676 ") "
2677 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2678 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002679 }
2680 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002681 skip |= LogError(
2682 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002683 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2684 "] "
2685 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2686 i);
2687 }
2688 }
sfricke-samsunge6669ec2021-11-29 23:33:03 -06002689
2690 if (depth_clip_control_struct) {
2691 const auto *depth_clip_control_features =
2692 LvlFindInChain<VkPhysicalDeviceDepthClipControlFeaturesEXT>(device_createinfo_pnext);
2693 const bool enabled_depth_clip_control =
2694 depth_clip_control_features && depth_clip_control_features->depthClipControl;
2695 if (depth_clip_control_struct->negativeOneToOne && !enabled_depth_clip_control) {
2696 skip |= LogError(device, "VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470",
2697 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2698 "].pViewportState has negativeOneToOne set to VK_TRUE in the pNext chain, but the "
2699 "depthClipControl feature is not enabled. ",
2700 i);
2701 }
2702 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002703 }
2704
2705 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002706 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002707 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2708 "].pRasterizationState->rasterizerDiscardEnable "
2709 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002710 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002711 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002712 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002713 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002714 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2715 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002716 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002717 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002718 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002719 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002720 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002721 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002722 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002723 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2724 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002725
2726 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002727 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002728 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002729 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002730
2731 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002732 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2734 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2735
2736 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002737 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002738 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2739 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002740 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002741 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002743 skip |= validate_flags(
2744 "vkCreateGraphicsPipelines",
2745 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2746 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002747 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002748
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002749 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002750 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002751 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2752 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2753
2754 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002755 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002756 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2757 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2758
2759 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002760 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002761 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2762 "].pMultisampleState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002763 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2764 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002765 }
John Zulauf7acac592017-11-06 11:15:53 -07002766 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002767 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002768 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2769 "vkCreateGraphicsPipelines(): parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002770 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002771 i);
John Zulauf7acac592017-11-06 11:15:53 -07002772 }
2773 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2774 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2775 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002776 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002777
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002778 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2779 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2780 "].pMultisampleState->minSampleShading.",
2781 i);
John Zulauf7acac592017-11-06 11:15:53 -07002782 }
2783 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002784
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002785 const auto *line_state =
2786 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002787
2788 if (line_state) {
2789 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2790 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2791 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2792 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2794 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002795 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002796 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002797 }
2798 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2799 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002800 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2801 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002802 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002803 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002804 }
2805 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2806 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002807 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2808 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002809 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002810 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002811 }
2812 }
2813 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2814 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2815 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002816 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002817 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2818 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002819 "range [1,256].",
2820 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002821 }
2822 }
2823 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002824 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002825 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2826 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002827 skip |=
2828 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002829 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2830 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002831 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2832 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002833 }
2834 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2835 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002836 skip |=
2837 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002838 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2839 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002840 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2841 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002842 }
2843 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2844 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002845 skip |=
2846 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002847 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2848 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002849 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2850 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002851 }
2852 if (line_state->stippledLineEnable) {
2853 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2854 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002855 skip |=
2856 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002857 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2858 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002859 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2860 "stippledRectangularLines feature.",
2861 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002862 }
2863 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2864 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002865 skip |=
2866 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002867 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2868 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2870 "stippledBresenhamLines feature.",
2871 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002872 }
2873 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2874 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002875 skip |=
2876 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002877 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2878 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002879 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2880 "stippledSmoothLines feature.",
2881 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002882 }
2883 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05002884 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002885 skip |=
2886 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002887 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2888 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002889 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2890 "stippledRectangularLines and strictLines features.",
2891 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002892 }
2893 }
2894 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895 }
2896
Petr Krause91f7a12017-12-14 20:57:36 +01002897 bool uses_color_attachment = false;
2898 bool uses_depthstencil_attachment = false;
Younggwan Kim26b9abd2021-12-07 21:22:03 +00002899 VkSubpassDescriptionFlags subpass_flags = 0;
Petr Krause91f7a12017-12-14 20:57:36 +01002900 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002901 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002902 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2903 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002904 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002905 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002906 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002907 }
2908 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002909 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002910 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00002911 subpass_flags = subpasses_uses.subpasses_flags[pCreateInfos[i].subpass];
Petr Krause91f7a12017-12-14 20:57:36 +01002912 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002913 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002914 }
2915
2916 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002917 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002918 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002920 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002921 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922
Mike Schuchardt00e81452021-11-29 11:11:20 -08002923 skip |=
2924 validate_flags("vkCreateGraphicsPipelines",
2925 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
2926 "VkPipelineDepthStencilStateCreateFlagBits", AllVkPipelineDepthStencilStateCreateFlagBits,
2927 pCreateInfos[i].pDepthStencilState->flags, kOptionalFlags,
2928 "VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002929
2930 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002931 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2933 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2934
2935 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002936 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002937 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2938 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2939
2940 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002941 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002942 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2943 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002944 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002945
2946 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002947 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002948 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2949 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2950
2951 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002952 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2954 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2955
2956 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002957 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2959 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002960 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961
2962 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002963 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2965 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002966 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002967
2968 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002969 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2971 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002972 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002973
2974 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002975 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2977 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002978 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979
2980 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002981 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002982 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2983 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002984 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002985
2986 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002987 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002988 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2989 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002990 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991
2992 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2995 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002996 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997
2998 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002999 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
3001 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003002 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003
3004 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003005 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003006 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3007 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003008 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
3009 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003010 }
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003011
3012 if ((pCreateInfos[i].pDepthStencilState->flags &
3013 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) != 0) {
3014 const auto *rasterization_order_attachment_access_feature =
3015 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3016 const bool rasterization_order_depth_attachment_access_feature_enabled =
3017 rasterization_order_attachment_access_feature &&
3018 rasterization_order_attachment_access_feature->rasterizationOrderDepthAttachmentAccess == VK_TRUE;
3019 if (!rasterization_order_depth_attachment_access_feature_enabled) {
3020 skip |= LogError(
3021 device, "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderDepthAttachmentAccess-06463",
3022 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3023 "rasterizationOrderDepthAttachmentAccess == VK_FALSE, but "
3024 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
3025 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str());
3026 }
3027
3028 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM) == 0) {
3029 skip |= LogError(
3030 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06468",
3031 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3032 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3033 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str(),
3034 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3035 }
3036 }
3037
3038 if ((pCreateInfos[i].pDepthStencilState->flags &
3039 VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) != 0) {
3040 const auto *rasterization_order_attachment_access_feature =
3041 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3042 const bool rasterization_order_stencil_attachment_access_feature_enabled =
3043 rasterization_order_attachment_access_feature &&
3044 rasterization_order_attachment_access_feature->rasterizationOrderStencilAttachmentAccess == VK_TRUE;
3045 if (!rasterization_order_stencil_attachment_access_feature_enabled) {
3046 skip |= LogError(
3047 device,
3048 "VUID-VkPipelineDepthStencilStateCreateInfo-rasterizationOrderStencilAttachmentAccess-06464",
3049 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3050 "rasterizationOrderStencilAttachmentAccess == VK_FALSE, but "
3051 "VkPipelineDepthStencilStateCreateInfo::flags == %s",
3052 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str());
3053 }
3054
3055 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM) == 0) {
3056 skip |= LogError(
3057 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06469",
3058 "VkPipelineDepthStencilStateCreateInfo::flags == %s but "
3059 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3060 string_VkPipelineDepthStencilStateCreateFlags(pCreateInfos[i].pDepthStencilState->flags).c_str(),
3061 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3062 }
3063 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003064 }
3065
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003066 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02003067 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
3068 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003069
Petr Krause91f7a12017-12-14 20:57:36 +01003070 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06003071 skip |= validate_struct_type("vkCreateGraphicsPipelines",
3072 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3073 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3074 pCreateInfos[i].pColorBlendState,
3075 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
3076 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
3077
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003078 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003079 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003080 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02003081 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003082 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
3083 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003084 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3085 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086
Mike Schuchardt00e81452021-11-29 11:11:20 -08003087 skip |= validate_flags("vkCreateGraphicsPipelines",
3088 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
3089 "VkPipelineColorBlendStateCreateFlagBits", AllVkPipelineColorBlendStateCreateFlagBits,
3090 pCreateInfos[i].pColorBlendState->flags, kOptionalFlags,
3091 "VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092
Younggwan Kim26b9abd2021-12-07 21:22:03 +00003093 if ((pCreateInfos[i].pColorBlendState->flags &
3094 VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM) != 0) {
3095 const auto *rasterization_order_attachment_access_feature =
3096 LvlFindInChain<VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM>(device_createinfo_pnext);
3097 const bool rasterization_order_color_attachment_access_feature_enabled =
3098 rasterization_order_attachment_access_feature &&
3099 rasterization_order_attachment_access_feature->rasterizationOrderColorAttachmentAccess == VK_TRUE;
3100
3101 if (!rasterization_order_color_attachment_access_feature_enabled) {
3102 skip |= LogError(
3103 device, "VUID-VkPipelineColorBlendStateCreateInfo-rasterizationOrderColorAttachmentAccess-06465",
3104 "VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM::"
3105 "rasterizationColorAttachmentAccess == VK_FALSE, but "
3106 "VkPipelineColorBlendStateCreateInfo::flags == %s",
3107 string_VkPipelineColorBlendStateCreateFlags(pCreateInfos[i].pColorBlendState->flags).c_str());
3108 }
3109
3110 if ((subpass_flags & VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM) == 0) {
3111 skip |= LogError(
3112 device, "VUID-VkGraphicsPipelineCreateInfo-flags-06467",
3113 "VkPipelineColorBlendStateCreateInfo::flags == %s but "
3114 "VkRenderPassCreateInfo::VkSubpassDescription::flags == %s",
3115 string_VkPipelineColorBlendStateCreateFlags(pCreateInfos[i].pColorBlendState->flags).c_str(),
3116 string_VkSubpassDescriptionFlags(subpass_flags).c_str());
3117 }
3118 }
3119
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003120 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003121 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003122 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
3123 pCreateInfos[i].pColorBlendState->logicOpEnable);
3124
3125 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003126 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003127 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3128 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00003129 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06003130 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131
3132 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003133 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
3134 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003135 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003136 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003137 ParameterName::IndexVector{i, attachment_index}),
3138 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139
3140 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003141 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003143 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003145 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003146 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
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].dstColorBlendFactor",
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].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003154 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-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].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003159 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003160 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003161 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003162 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-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].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003167 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003169 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003170 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-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].dstAlphaBlendFactor",
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].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003178 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-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].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003183 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003184 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003185 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003186 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003187
3188 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003189 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003191 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003192 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003193 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003194 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003195
3196 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3197 bool invalid = false;
3198 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3199 case VK_BLEND_OP_ZERO_EXT:
3200 case VK_BLEND_OP_SRC_EXT:
3201 case VK_BLEND_OP_DST_EXT:
3202 case VK_BLEND_OP_SRC_OVER_EXT:
3203 case VK_BLEND_OP_DST_OVER_EXT:
3204 case VK_BLEND_OP_SRC_IN_EXT:
3205 case VK_BLEND_OP_DST_IN_EXT:
3206 case VK_BLEND_OP_SRC_OUT_EXT:
3207 case VK_BLEND_OP_DST_OUT_EXT:
3208 case VK_BLEND_OP_SRC_ATOP_EXT:
3209 case VK_BLEND_OP_DST_ATOP_EXT:
3210 case VK_BLEND_OP_XOR_EXT:
3211 case VK_BLEND_OP_INVERT_EXT:
3212 case VK_BLEND_OP_INVERT_RGB_EXT:
3213 case VK_BLEND_OP_LINEARDODGE_EXT:
3214 case VK_BLEND_OP_LINEARBURN_EXT:
3215 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3216 case VK_BLEND_OP_LINEARLIGHT_EXT:
3217 case VK_BLEND_OP_PINLIGHT_EXT:
3218 case VK_BLEND_OP_HARDMIX_EXT:
3219 case VK_BLEND_OP_PLUS_EXT:
3220 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3221 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3222 case VK_BLEND_OP_PLUS_DARKER_EXT:
3223 case VK_BLEND_OP_MINUS_EXT:
3224 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3225 case VK_BLEND_OP_CONTRAST_EXT:
3226 case VK_BLEND_OP_INVERT_OVG_EXT:
3227 case VK_BLEND_OP_RED_EXT:
3228 case VK_BLEND_OP_GREEN_EXT:
3229 case VK_BLEND_OP_BLUE_EXT:
3230 invalid = true;
3231 break;
3232 default:
3233 break;
3234 }
3235 if (invalid) {
3236 skip |= LogError(
3237 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3238 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3239 "].pColorBlendState->pAttachments[%" PRIu32
3240 "].colorBlendOp (%s) is not valid when "
3241 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3242 "VK_FALSE",
3243 i, attachment_index,
3244 string_VkBlendOp(
3245 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3246 }
3247 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003248 }
3249 }
3250
3251 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003252 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003253 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3254 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003255 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3256 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003257 }
3258
3259 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3260 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3261 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003262 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003263 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003264 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3265 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003266 }
3267 }
3268 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003269
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003270 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3271 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003272 if (pCreateInfos[i].basePipelineIndex != -1) {
3273 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003274 skip |=
3275 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003276 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3277 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003278 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003279 "and pCreateInfos->basePipelineIndex is not -1.",
3280 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003281 }
3282 }
3283
Petr Kraus9752aae2017-11-24 03:05:50 +01003284 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3285 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003286 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003287 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3288 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003289 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003290 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3291 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003292 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003293 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003294 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003295 skip |=
3296 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003297 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3298 ") must be a valid"
3299 "index into the pCreateInfos array, of size %" PRIu32 ".",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003300 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003301 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003302 }
3303 }
3304
Petr Kraus9752aae2017-11-24 03:05:50 +01003305 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003306 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003307 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3308 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003309 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3310 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3311 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3312 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003313 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3314 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003315 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003316 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003317 "pCreateInfos[%" PRIu32
3318 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003319 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3320 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003321 }
3322 } else {
3323 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3324 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3325 (physical_device_features.fillModeNonSolid == false)) {
3326 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003327 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3328 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003329 "pCreateInfos[%" PRIu32
3330 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003331 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3332 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003333 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003334 }
Petr Kraus299ba622017-11-24 03:09:03 +01003335
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003336 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003337 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003338 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3339 "The line width state is static (pCreateInfos[%" PRIu32
3340 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3341 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3342 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3343 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003344 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003345 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003346
3347 // Validate no flags not allowed are used
3348 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003349 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003350 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3351 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003352 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3353 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003354 }
3355 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003356 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003357 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3358 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003359 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3360 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003361 }
3362 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3363 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003364 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3365 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003366 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3367 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003368 }
3369 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3370 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003371 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3372 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003373 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3374 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003375 }
3376 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3377 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003378 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3379 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003380 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3381 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003382 }
3383 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3384 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003385 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3386 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003387 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3388 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003389 }
3390 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3391 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003392 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3393 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003394 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3395 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003396 }
3397 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3398 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003399 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3400 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003401 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3402 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003403 }
3404 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3405 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003406 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3407 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003408 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3409 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003410 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003411 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3412 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3413 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3414 "]->flags (0x%x) must not include "
3415 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3416 i, flags);
3417 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003418 }
3419 }
3420
3421 return skip;
3422}
3423
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003424bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3425 uint32_t createInfoCount,
3426 const VkComputePipelineCreateInfo *pCreateInfos,
3427 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003428 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003431 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003433 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003434 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003435 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003436 skip |=
3437 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3438 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3439 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3440 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003441 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003442
3443 // Make sure compute stage is selected
3444 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003445 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003446 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3447 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003448 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003449 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003450
sfricke-samsungeb549012021-04-16 01:25:51 -07003451 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3452 // Validate no flags not allowed are used
3453 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003454 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3455 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3456 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3457 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003458 }
3459 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3460 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003461 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3462 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003463 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3464 i, flags);
3465 }
3466 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3467 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003468 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3469 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003470 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3471 i, flags);
3472 }
3473 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3474 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003475 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3476 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003477 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3478 i, flags);
3479 }
3480 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3481 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003482 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3483 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003484 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3485 i, flags);
3486 }
3487 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3488 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003489 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3490 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003491 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3492 i, flags);
3493 }
3494 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3495 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003496 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3497 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003498 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3499 i, flags);
3500 }
3501 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3502 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003503 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3504 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003505 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3506 i, flags);
3507 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003508 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3509 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003510 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3511 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003512 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3513 i, flags);
3514 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003515 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3516 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003517 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3518 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003519 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3520 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003521 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003522 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3523 if (pCreateInfos[i].basePipelineIndex != -1) {
3524 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3525 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3526 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3527 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3528 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3529 i);
3530 }
3531 }
3532
3533 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3534 if (pCreateInfos[i].basePipelineIndex != -1) {
3535 skip |= LogError(
3536 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3537 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3538 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3539 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3540 i);
3541 }
3542 } else {
3543 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3544 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3545 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3546 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3547 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3548 }
3549 }
3550 }
ziga-lunargc6341372021-07-28 12:57:42 +02003551
3552 std::stringstream msg;
3553 msg << "pCreateInfos[%" << i << "].stage";
3554 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003555 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003556 return skip;
3557}
3558
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003559bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003560 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003561 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003562
3563 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003564 const auto &features = physical_device_features;
3565 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003566
John Zulauf71968502017-10-26 13:51:15 -06003567 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3568 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003569 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3570 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3571 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3572 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003573 }
3574
3575 // Anistropy cannot be enabled in sampler unless enabled as a feature
3576 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003577 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3578 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3579 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003580 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003581 }
John Zulauf71968502017-10-26 13:51:15 -06003582
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003583 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3584 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003585 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3586 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3587 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3588 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003589 }
3590 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003591 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3592 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3593 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3594 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003595 }
3596 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003597 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3598 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3599 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3600 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003601 }
3602 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3603 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3604 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3605 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003606 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3607 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3608 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3609 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3610 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3611 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003612 }
3613 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003614 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3615 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3616 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003617 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003618 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003619 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3620 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3621 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003622 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003623 }
3624
3625 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3626 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003627 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3628 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003629 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003630 if (sampler_reduction != nullptr) {
3631 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3632 skip |= LogError(
3633 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3634 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3635 }
3636 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003637 }
3638
3639 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3640 // valid VkBorderColor value
3641 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3642 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3643 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003644 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3645 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003646 }
3647
John Zulauf275805c2017-10-26 15:34:49 -06003648 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003649 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003650 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3651 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003652 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3653 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3654 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003655 }
3656 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003657
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003658 // Check for valid Lod range
3659 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003660 skip |=
3661 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3662 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003663 }
3664
3665 // Check mipLodBias to device limit
3666 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003667 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3668 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3669 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003670 }
3671
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003672 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003673 if (sampler_conversion != nullptr) {
3674 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3675 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3676 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3677 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003678 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003679 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003680 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3681 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3682 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3683 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3684 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3685 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3686 }
3687 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003688
3689 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3690 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3691 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3692 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3693 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3694 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3695 }
3696 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3697 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3698 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3699 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3700 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3701 }
3702 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3703 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3704 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3705 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3706 pCreateInfo->minLod, pCreateInfo->maxLod);
3707 }
3708 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3709 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3710 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3711 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3712 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3713 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3714 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3715 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3716 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3717 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3718 }
3719 if (pCreateInfo->anisotropyEnable) {
3720 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3721 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3722 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3723 }
3724 if (pCreateInfo->compareEnable) {
3725 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3726 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3727 "pCreateInfo->compareEnable must be VK_FALSE");
3728 }
3729 if (pCreateInfo->unnormalizedCoordinates) {
3730 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3731 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3732 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3733 }
3734 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003735
Piers Daniell833b9492021-11-20 11:47:10 -07003736 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3737 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3738 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3739 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3740 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3741 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3742 }
3743 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3744 if (!custom_create_info) {
3745 skip |= LogError(
3746 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3747 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3748 "struct in pNext chain.\n",
3749 string_VkBorderColor(pCreateInfo->borderColor));
3750 } else {
3751 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3752 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3753 !FormatIsSampledInt(custom_create_info->format)) ||
3754 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3755 !FormatIsSampledFloat(custom_create_info->format)))) {
3756 skip |=
3757 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003758 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3759 "whose type does not match\n",
3760 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003761 ;
3762 }
3763 }
3764 }
3765
3766 const auto *border_color_component_mapping =
3767 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3768 if (border_color_component_mapping) {
3769 const auto *border_color_swizzle_features =
3770 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
3771 bool border_color_swizzle_features_enabled =
3772 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
3773 if (!border_color_swizzle_features_enabled) {
3774 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
3775 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
3776 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06003777 }
3778 }
3779 }
3780
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003781 return skip;
3782}
3783
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003784bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3785 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3786 const char *func_name) const {
3787 bool skip = false;
3788
3789 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3790 uint32_t mutable_type_count = 0;
3791 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3792 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3793 }
3794 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3795 if (mutable_type_count == 0) {
3796 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3797 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3798 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3799 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3800 "].descriptorTypeCount is 0.",
3801 func_name, i, i);
3802 }
3803 } else {
3804 if (mutable_type_count > 0) {
3805 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3806 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3807 "].descriptorType is %s, but "
3808 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3809 "].descriptorTypeCount is not 0.",
3810 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3811 }
3812 }
3813 }
3814
3815 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3816 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3817 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3818 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3819 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
3820 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3821 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
3822 func_name, j, k);
3823 break;
3824 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
3825 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
3826 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3827 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
3828 func_name, j, k);
3829 break;
3830 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
3831 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
3832 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3833 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
3834 func_name, j, k);
3835 break;
3836 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
3837 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
3838 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3839 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
3840 func_name, j, k);
3841 break;
3842 default:
3843 break;
3844 }
3845 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
3846 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
3847 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
3848 skip |=
3849 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
3850 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3851 "].pDescriptorTypes[%" PRIu32
3852 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3853 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
3854 func_name, j, k, j, l,
3855 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
3856 }
3857 }
3858 }
3859 }
3860
3861 return skip;
3862}
3863
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003864bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3865 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3866 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003867 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003868 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003869
ziga-lunargfc6896f2021-10-15 18:46:12 +02003870 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
3871 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
3872 bool mutable_descriptor_type_features_enabled =
3873 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
3874
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003875 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3876 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3877 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3878 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003879 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3880 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3881 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3882 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3883 ++descriptor_index) {
3884 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003885 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003886 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003887 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
3888 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003889 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003890 }
3891 }
3892 }
3893
3894 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3895 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3896 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003897 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003898 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3899 "].descriptorCount is not 0, "
3900 "pCreateInfo->pBindings[%" PRIu32
3901 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003902 "values.",
3903 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003904 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003905
3906 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3907 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3908 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003909 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3910 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3911 "].descriptorCount is not 0 and "
3912 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
3913 "].stageFlags "
3914 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3915 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003916 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003917
3918 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3919 if (!mutable_descriptor_type) {
3920 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
3921 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3922 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3923 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
3924 i);
3925 }
3926 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
3927 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
3928 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3929 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3930 "pImmutableSamplers is not NULL.",
3931 i);
3932 }
3933 if (!mutable_descriptor_type_features_enabled) {
3934 skip |= LogError(
3935 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
3936 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3937 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3938 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
3939 i);
3940 }
3941 }
3942
3943 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
3944 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3945 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
3946 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3947 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
3948 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
3949 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003950 }
3951 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003952
3953 if (mutable_descriptor_type) {
3954 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
3955 "vkDescriptorSetLayoutCreateInfo");
3956 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003957 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003958 if (pCreateInfo) {
3959 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
3960 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3961 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
3962 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3963 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
3964 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3965 }
3966 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
3967 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3968 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
3969 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3970 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
3971 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3972 }
3973 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
3974 !mutable_descriptor_type_features_enabled) {
3975 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
3976 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3977 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
3978 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
3979 }
3980 }
3981
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003982 return skip;
3983}
3984
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003985bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3986 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003987 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003988 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3989 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3990 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003991 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3992 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003993}
3994
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003995bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3996 const VkWriteDescriptorSet *pDescriptorWrites,
3997 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003998 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003999
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004000 if (pDescriptorWrites != NULL) {
4001 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
4002 // descriptorCount must be greater than 0
4003 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004004 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
4005 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
4006 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004007 }
4008
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004009 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
4010 if (validateDstSet) {
4011 // dstSet must be a valid VkDescriptorSet handle
4012 skip |= validate_required_handle(vkCallingFunction,
4013 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
4014 pDescriptorWrites[i].dstSet);
4015 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004016
4017 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
4018 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
4019 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
4020 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
4021 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
4022 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4023 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05004024 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
4025 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004026 if (pDescriptorWrites[i].pImageInfo == nullptr) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004027 skip |=
4028 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
4029 "%s(): if pDescriptorWrites[%" PRIu32
4030 "].descriptorType is "
4031 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
4032 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
4033 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
4034 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004035 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
4036 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05004037 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
4038 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004039 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4040 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004041 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004042 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
4043 ParameterName::IndexVector{i, descriptor_index}),
4044 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06004045 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004046 }
4047 }
4048 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4049 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4050 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
4051 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
4052 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4053 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
4054 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05004055 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004056 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004057 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004058 "%s(): if pDescriptorWrites[%" PRIu32
4059 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004060 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
4061 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004062 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004063 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004064 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05004065 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004066 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05004067 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004068 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
4069 ++descriptor_index) {
4070 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
4071 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
4072 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004073 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004074 "%s(): if pDescriptorWrites[%" PRIu32
4075 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01004076 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004077 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
4078 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05004079 }
4080 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004081 }
4082 }
4083 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
4084 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05004085 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004086 }
4087
4088 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
4089 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004090 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004091 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4092 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004093 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004094 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004095 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004096 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004097 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004098 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004099 }
4100 }
4101 }
4102 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4103 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004104 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004105 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4106 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004107 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004108 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004109 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004110 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004111 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004112 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004113 }
4114 }
4115 }
4116 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004117 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4118 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004119 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004120 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004121 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4122 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4123 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4124 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004125 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004126 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4127 pDescriptorWrites[i].descriptorCount);
4128 }
4129 // further checks only if we have right structtype
4130 if (pnext_struct) {
4131 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4132 skip |= LogError(
4133 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004134 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4135 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004136 ".",
4137 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004138 }
sourav parmarbcee7512020-12-28 14:34:49 -08004139 if (pnext_struct->accelerationStructureCount == 0) {
4140 skip |= LogError(device,
4141 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004142 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004143 }
4144 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004145 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004146 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4147 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4148 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4149 skip |= LogError(device,
4150 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4151 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004152 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004153 }
4154 }
4155 }
sourav parmarbcee7512020-12-28 14:34:49 -08004156 }
4157 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004158 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004159 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4160 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4161 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4162 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004163 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004164 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4165 pDescriptorWrites[i].descriptorCount);
4166 }
4167 // further checks only if we have right structtype
4168 if (pnext_struct) {
4169 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4170 skip |= LogError(
4171 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004172 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4173 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004174 ".",
4175 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004176 }
sourav parmarbcee7512020-12-28 14:34:49 -08004177 if (pnext_struct->accelerationStructureCount == 0) {
4178 skip |= LogError(device,
4179 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004180 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004181 }
4182 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004183 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004184 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4185 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4186 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4187 skip |= LogError(device,
4188 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4189 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004190 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004191 }
4192 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004193 }
4194 }
4195 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004196 }
4197 }
4198 return skip;
4199}
4200
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004201bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4202 const VkWriteDescriptorSet *pDescriptorWrites,
4203 uint32_t descriptorCopyCount,
4204 const VkCopyDescriptorSet *pDescriptorCopies) const {
4205 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
4206}
4207
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004208bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004209 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004210 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004211 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4212}
4213
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004214bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4215 const VkAllocationCallbacks *pAllocator,
4216 VkRenderPass *pRenderPass) const {
4217 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4218}
4219
Mike Schuchardt2df08912020-12-15 16:28:09 -08004220bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004221 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004222 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004223 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4224}
4225
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004226bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4227 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004228 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004229 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004230
4231 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4232 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4233 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004234 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4235 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004236 return skip;
4237}
4238
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004239bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004240 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004241 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004242
4243 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4244 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004245 bool cb_is_secondary;
4246 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004247 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004248 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4249 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004250
Tony-LunarG3c287f62020-12-17 12:39:49 -07004251 if (cb_is_secondary) {
4252 // Implicit VUs
4253 // validate only sType here; pointer has to be validated in core_validation
4254 const bool k_not_required = false;
4255 const char *k_no_vuid = nullptr;
4256 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4257 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004258 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4259 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004260
Tony-LunarG3c287f62020-12-17 12:39:49 -07004261 if (info) {
4262 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004263 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004264 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4265 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004266 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004267 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004268 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4269 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4270 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4271 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004272
Tony-LunarG3c287f62020-12-17 12:39:49 -07004273 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004274
Tony-LunarG3c287f62020-12-17 12:39:49 -07004275 // Explicit VUs
4276 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004277 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004278 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4279 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4280 cmd_name);
4281 }
4282
4283 if (physical_device_features.inheritedQueries) {
4284 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004285 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4286 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4287 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004288 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004289 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004290 }
4291
4292 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004293 skip |=
4294 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4295 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4296 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4297 } else { // !pipelineStatisticsQuery
4298 skip |=
4299 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4300 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004301 }
4302
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004303 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004304 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004305 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004306 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4307 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4308 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004309 commandBuffer,
4310 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004311 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4312 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4313 }
Petr Kraus139757b2019-08-15 17:19:33 +02004314 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004315
4316 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4317 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4318 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4319 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4320 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4321 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4322 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4323 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4324 }
Petr Kraus139757b2019-08-15 17:19:33 +02004325 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004326 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004327 return skip;
4328}
4329
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004330bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004331 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004332 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004333
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004334 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004335 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004336 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4337 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4338 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004339 }
4340 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004341 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4342 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4343 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004344 }
4345 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004346 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004347 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004348 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4349 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4350 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4351 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004352 }
4353 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004354
4355 if (pViewports) {
4356 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4357 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004358 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004359 skip |= manual_PreCallValidateViewport(
4360 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004361 }
4362 }
4363
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004364 return skip;
4365}
4366
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004367bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004368 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004369 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004370
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004371 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004372 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004373 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4374 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4375 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004376 }
4377 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004378 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4379 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4380 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004381 }
4382 } else { // multiViewport enabled
4383 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004384 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004385 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4386 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4387 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4388 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004389 }
4390 }
4391
Petr Kraus6260f0a2018-02-27 21:15:55 +01004392 if (pScissors) {
4393 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4394 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004395
Petr Kraus6260f0a2018-02-27 21:15:55 +01004396 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4398 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4399 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004400 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004401
Petr Kraus6260f0a2018-02-27 21:15:55 +01004402 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004403 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4404 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4405 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004406 }
4407
4408 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4409 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004410 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4411 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4412 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4413 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004414 }
4415
4416 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4417 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004418 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4419 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4420 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4421 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004422 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004423 }
4424 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004425
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004426 return skip;
4427}
4428
Jeff Bolz5c801d12019-10-09 10:38:45 -05004429bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004430 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004432 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004433 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4434 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004435 }
4436
4437 return skip;
4438}
4439
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004440bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004441 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004442 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004443
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004444 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004445 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004446 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4447 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004448 }
4449 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004450 skip |=
4451 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4452 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4453 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004454 }
4455 return skip;
4456}
4457
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004458bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004459 VkDeviceSize offset, uint32_t drawCount,
4460 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004461 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004462 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004463 skip |=
4464 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4465 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4466 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004467 }
4468 if (drawCount > device_limits.maxDrawIndirectCount) {
4469 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004470 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4471 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004472 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004473 }
4474 return skip;
4475}
4476
sfricke-samsungf692b972020-05-02 08:00:45 -07004477bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4478 VkDeviceSize countBufferOffset, bool khr) const {
4479 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004480 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004481 if (offset & 3) {
4482 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004483 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004484 }
4485
4486 if (countBufferOffset & 3) {
4487 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004488 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004489 countBufferOffset);
4490 }
4491 return skip;
4492}
4493
4494bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4495 VkDeviceSize offset, VkBuffer countBuffer,
4496 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4497 uint32_t stride) const {
4498 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4499}
4500
4501bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4502 VkDeviceSize offset, VkBuffer countBuffer,
4503 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4504 uint32_t stride) const {
4505 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4506}
4507
4508bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4509 VkDeviceSize countBufferOffset, bool khr) const {
4510 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004511 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004512 if (offset & 3) {
4513 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004514 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004515 }
4516
4517 if (countBufferOffset & 3) {
4518 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004519 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004520 countBufferOffset);
4521 }
4522 return skip;
4523}
4524
4525bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4526 VkDeviceSize offset, VkBuffer countBuffer,
4527 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4528 uint32_t stride) const {
4529 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4530}
4531
4532bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4533 VkDeviceSize offset, VkBuffer countBuffer,
4534 VkDeviceSize countBufferOffset,
4535 uint32_t maxDrawCount, uint32_t stride) const {
4536 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4537}
4538
Tony-LunarG4490de42021-06-21 15:49:19 -06004539bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4540 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4541 uint32_t firstInstance, uint32_t stride) const {
4542 bool skip = false;
4543 if (stride & 3) {
4544 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4545 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4546 }
4547 if (drawCount && nullptr == pVertexInfo) {
4548 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4549 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4550 "one or more valid instances of VkMultiDrawInfoEXT structures");
4551 }
4552 return skip;
4553}
4554
4555bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4556 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4557 uint32_t instanceCount, uint32_t firstInstance,
4558 uint32_t stride, const int32_t *pVertexOffset) const {
4559 bool skip = false;
4560 if (stride & 3) {
4561 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4562 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4563 }
4564 if (drawCount && nullptr == pIndexInfo) {
4565 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4566 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4567 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4568 }
4569 return skip;
4570}
4571
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004572bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4573 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004574 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004575 bool skip = false;
4576 for (uint32_t rect = 0; rect < rectCount; rect++) {
4577 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004578 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004579 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004580 }
sfricke-samsung10867682020-04-25 02:20:39 -07004581 if (pRects[rect].rect.extent.width == 0) {
4582 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004583 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004584 }
4585 if (pRects[rect].rect.extent.height == 0) {
4586 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004587 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004588 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004589 }
4590 return skip;
4591}
4592
Andrew Fobel3abeb992020-01-20 16:33:22 -05004593bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4594 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4595 VkImageFormatProperties2 *pImageFormatProperties,
4596 const char *apiName) const {
4597 bool skip = false;
4598
4599 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004600 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004601 if (image_stencil_struct != nullptr) {
4602 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4603 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4604 // No flags other than the legal attachment bits may be set
4605 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4606 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004607 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4608 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4609 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4610 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4611 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004612 }
4613 }
4614 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004615 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4616 if (image_drm_format) {
4617 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4618 skip |= LogError(
4619 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4620 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4621 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4622 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4623 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004624 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4625 skip |= LogError(
4626 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4627 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4628 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4629 apiName, image_drm_format->queueFamilyIndexCount);
4630 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004631 } else {
4632 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4633 skip |= LogError(
4634 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4635 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4636 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4637 apiName);
4638 }
4639 }
4640 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4641 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4642 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4643 if (!format_list || format_list->viewFormatCount == 0) {
4644 skip |= LogError(
4645 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4646 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4647 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4648 apiName);
4649 }
4650 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004651 }
4652
4653 return skip;
4654}
4655
4656bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4657 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4658 VkImageFormatProperties2 *pImageFormatProperties) const {
4659 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4660 "vkGetPhysicalDeviceImageFormatProperties2");
4661}
4662
4663bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4664 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4665 VkImageFormatProperties2 *pImageFormatProperties) const {
4666 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4667 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4668}
4669
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004670bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4671 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4672 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4673 bool skip = false;
4674
4675 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4676 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4677 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4678 }
4679
4680 return skip;
4681}
4682
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004683bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4684 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4685 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4686 bool skip = false;
4687
4688 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4689 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4690 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4691 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4692 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4693 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4694 }
4695
ziga-lunarg42f884b2021-08-25 16:13:20 +02004696 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004697}
4698
sfricke-samsung3999ef62020-02-09 17:05:59 -08004699bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4700 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4701 bool skip = false;
4702
4703 if (pRegions != nullptr) {
4704 for (uint32_t i = 0; i < regionCount; i++) {
4705 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004706 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004707 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004708 }
4709 }
4710 }
4711 return skip;
4712}
4713
Jeff Leger178b1e52020-10-05 12:22:23 -04004714bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4715 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4716 bool skip = false;
4717
4718 if (pCopyBufferInfo->pRegions != nullptr) {
4719 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4720 if (pCopyBufferInfo->pRegions[i].size == 0) {
4721 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004722 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004723 }
4724 }
4725 }
4726 return skip;
4727}
4728
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004729bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004730 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4731 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004732 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004733
4734 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004735 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4736 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4737 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004738 }
4739
4740 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004741 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4742 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4743 "), must be greater than zero and less than or equal to 65536.",
4744 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004745 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004746 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4747 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4748 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004749 }
4750 return skip;
4751}
4752
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004753bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004754 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004755 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004756
4757 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004758 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4759 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4760 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004761 }
4762
4763 if (size != VK_WHOLE_SIZE) {
4764 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004765 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004766 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4767 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004768 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004769 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4770 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004771 }
4772 }
4773 return skip;
4774}
4775
sfricke-samsunga1d00272021-03-10 21:37:41 -08004776bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004777 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004778
4779 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004780 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4781 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4782 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4783 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004784 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004785 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4786 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4787 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004788 }
4789
4790 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4791 // queueFamilyIndexCount uint32_t values
4792 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004793 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004794 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004795 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004796 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4797 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004798 }
4799 }
4800
Dave Houlton413a6782018-05-22 13:01:54 -06004801 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004802 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004803
sfricke-samsunga1d00272021-03-10 21:37:41 -08004804 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4805 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4806 if (format_list_info) {
4807 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4808 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4809 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4810 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004811 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4812 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004813 func_name, viewFormatCount);
4814 }
4815
4816 // Using the first format, compare the rest of the formats against it that they are compatible
4817 for (uint32_t i = 1; i < viewFormatCount; i++) {
4818 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4819 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4820 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4821 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004822 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4823 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004824 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4825 string_VkFormat(format_list_info->pViewFormats[i]));
4826 }
4827 }
4828 }
4829
4830 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4831 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4832 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4833 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4834 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4835 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4836 func_name);
4837 } else {
4838 if (format_list_info == nullptr) {
4839 skip |= LogError(
4840 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4841 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4842 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4843 func_name);
4844 } else if (format_list_info->viewFormatCount == 0) {
4845 skip |= LogError(
4846 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4847 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4848 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4849 func_name);
4850 } else {
4851 bool found_base_format = false;
4852 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4853 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4854 found_base_format = true;
4855 break;
4856 }
4857 }
4858 if (!found_base_format) {
4859 skip |=
4860 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4861 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4862 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4863 "pCreateInfo->imageFormat.",
4864 func_name);
4865 }
4866 }
4867 }
4868 }
4869 }
4870 return skip;
4871}
4872
4873bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4874 const VkAllocationCallbacks *pAllocator,
4875 VkSwapchainKHR *pSwapchain) const {
4876 bool skip = false;
4877 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4878 return skip;
4879}
4880
4881bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4882 const VkSwapchainCreateInfoKHR *pCreateInfos,
4883 const VkAllocationCallbacks *pAllocator,
4884 VkSwapchainKHR *pSwapchains) const {
4885 bool skip = false;
4886 if (pCreateInfos) {
4887 for (uint32_t i = 0; i < swapchainCount; i++) {
4888 std::stringstream func_name;
4889 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4890 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4891 }
4892 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004893 return skip;
4894}
4895
Jeff Bolz5c801d12019-10-09 10:38:45 -05004896bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004897 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004898
4899 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004900 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004901 if (present_regions) {
4902 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004903 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004904 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4905 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004906 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004907 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4908 "extension swapchainCount is %i. These values must be equal.",
4909 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004910 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004911 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004912 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4913 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004914 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4915 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4916 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004917 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004918 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004919 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004920 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004921 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004922 }
4923 }
4924
4925 return skip;
4926}
4927
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004928bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4929 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4930 const VkAllocationCallbacks *pAllocator,
4931 VkDisplayModeKHR *pMode) const {
4932 bool skip = false;
4933
4934 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4935 if (display_mode_parameters.visibleRegion.width == 0) {
4936 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4937 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4938 }
4939 if (display_mode_parameters.visibleRegion.height == 0) {
4940 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4941 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4942 }
4943 if (display_mode_parameters.refreshRate == 0) {
4944 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4945 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4946 }
4947
4948 return skip;
4949}
4950
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004951#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004952bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4953 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4954 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004955 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004956 bool skip = false;
4957
4958 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004959 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4960 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004961 }
4962
4963 return skip;
4964}
4965#endif // VK_USE_PLATFORM_WIN32_KHR
4966
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004967static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
4968 bool partial_overlap = false;
4969
4970 static const std::vector<VkDescriptorType> all_descriptor_types = {
4971 VK_DESCRIPTOR_TYPE_SAMPLER,
4972 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4973 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4974 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4975 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4976 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4977 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4978 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4979 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
4980 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
4981 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
4982 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
4983 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
4984 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
4985 };
4986
4987 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4988 if (mutable_descriptor_type) {
4989 std::vector<VkDescriptorType> first_types, second_types;
4990 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
4991 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
4992 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
4993 }
4994 } else {
4995 first_types = all_descriptor_types;
4996 }
4997 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
4998 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4999 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
5000 }
5001 } else {
5002 second_types = all_descriptor_types;
5003 }
5004
5005 bool complete_overlap = first_types.size() == second_types.size();
5006 bool disjoint = true;
5007 for (const auto first_type : first_types) {
5008 bool found = false;
5009 for (const auto second_type : second_types) {
5010 if (first_type == second_type) {
5011 found = true;
5012 break;
5013 }
5014 }
5015 if (found) {
5016 disjoint = false;
5017 } else {
5018 complete_overlap = false;
5019 }
5020 if (!disjoint && !complete_overlap) {
5021 partial_overlap = true;
5022 break;
5023 }
5024 }
5025 }
5026
5027 return partial_overlap;
5028}
5029
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005030bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005031 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005032 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02005033 bool skip = false;
5034
5035 if (pCreateInfo) {
5036 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005037 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
5038 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02005039 }
5040
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005041 const auto *mutable_descriptor_type_features =
5042 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
5043 bool mutable_descriptor_type_enabled =
5044 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
5045
Petr Krausc8655be2017-09-27 18:56:51 +02005046 if (pCreateInfo->pPoolSizes) {
5047 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
5048 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005049 skip |= LogError(
5050 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005051 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02005052 }
Jeff Bolze54ae892018-09-08 12:16:29 -05005053 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
5054 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005055 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
5056 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5057 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
5058 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
5059 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05005060 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005061 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
5062 skip |=
5063 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
5064 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5065 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5066 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
5067 i);
5068 }
5069 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5070 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
5071 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
5072 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
5073 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
5074 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
5075 "].type and pCreateInfo->pPoolSizes[%" PRIu32
5076 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
5077 " and have sets which partially overlap.",
5078 i, j);
5079 }
5080 }
5081 }
5082 }
Petr Krausc8655be2017-09-27 18:56:51 +02005083 }
5084 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005085
ziga-lunarg0bc679d2021-10-15 15:55:19 +02005086 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
5087 skip |=
5088 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
5089 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
5090 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
5091 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02005092 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
5093 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
5094 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
5095 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
5096 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
5097 }
Petr Krausc8655be2017-09-27 18:56:51 +02005098 }
5099
5100 return skip;
5101}
5102
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005103bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005104 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005105 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005106
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005107 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005108 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005109 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5110 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5111 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005112 }
5113
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005114 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005115 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005116 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5117 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5118 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005119 }
5120
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005121 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005122 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005123 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5124 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5125 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005126 }
5127
5128 return skip;
5129}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005130
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005131bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005132 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005133 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005134
5135 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005136 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5137 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005138 }
5139 return skip;
5140}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005141
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005142bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5143 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005144 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005145 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005146
5147 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005148 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005149 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005150 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5151 "vkCmdDispatch(): baseGroupX (%" PRIu32
5152 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5153 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005154 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005155 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5156 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5157 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5158 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005159 }
5160
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005161 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005162 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005163 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5164 "vkCmdDispatch(): baseGroupY (%" PRIu32
5165 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5166 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005167 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005168 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5169 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5170 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5171 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005172 }
5173
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005174 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005175 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005176 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5177 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5178 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5179 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005180 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005181 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5182 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5183 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5184 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005185 }
5186
5187 return skip;
5188}
5189
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005190bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5191 VkPipelineBindPoint pipelineBindPoint,
5192 VkPipelineLayout layout, uint32_t set,
5193 uint32_t descriptorWriteCount,
5194 const VkWriteDescriptorSet *pDescriptorWrites) const {
5195 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
5196}
5197
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005198bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5199 uint32_t firstExclusiveScissor,
5200 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005201 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005202 bool skip = false;
5203
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005204 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005205 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005206 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005207 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5208 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5209 ") is not 0.",
5210 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005211 }
5212 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005213 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005214 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5215 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5216 ") is not 1.",
5217 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005218 }
5219 } else { // multiViewport enabled
5220 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005221 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005222 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5223 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5224 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5225 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005226 }
5227 }
5228
Jeff Bolz3e71f782018-08-29 23:15:45 -05005229 if (pExclusiveScissors) {
5230 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5231 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5232
5233 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005234 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5235 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5236 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005237 }
5238
5239 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005240 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5241 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5242 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005243 }
5244
5245 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5246 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005247 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5248 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5249 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5250 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005251 }
5252
5253 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5254 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005255 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5256 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5257 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5258 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005259 }
5260 }
5261 }
5262
5263 return skip;
5264}
5265
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005266bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5267 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005268 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005269 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005270 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5271 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5272 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5273 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5274 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5275 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005276 }
5277
5278 return skip;
5279}
5280
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005281bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5282 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005283 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005284 bool skip = false;
5285
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005286 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005287 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005288 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005289 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5290 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5291 ") is not 0.",
5292 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005293 }
5294 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005295 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005296 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5297 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5298 ") is not 1.",
5299 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005300 }
5301 }
5302
Jeff Bolz9af91c52018-09-01 21:53:57 -05005303 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005304 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005305 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5306 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5307 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5308 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005309 }
5310
5311 return skip;
5312}
5313
Jeff Bolz5c801d12019-10-09 10:38:45 -05005314bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5315 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5316 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005317 bool skip = false;
5318
Dave Houlton142c4cb2018-10-17 15:04:41 -06005319 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005320 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5321 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5322 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005323 }
5324
5325 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005326 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005327 }
5328
5329 return skip;
5330}
5331
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005332bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005333 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005334 bool skip = false;
5335
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005336 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005337 skip |= LogError(
5338 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005339 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5340 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005341 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005342 }
5343
5344 return skip;
5345}
5346
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005347bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5348 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005349 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005350 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005351 static const int condition_multiples = 0b0011;
5352 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005353 skip |= LogError(
5354 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005355 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005356 }
Lockee1c22882019-06-10 16:02:54 -06005357 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005358 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5359 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5360 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5361 stride);
Lockee1c22882019-06-10 16:02:54 -06005362 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005363 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005364 skip |= LogError(
5365 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005366 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5367 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005368 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005369 if (drawCount > device_limits.maxDrawIndirectCount) {
5370 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005371 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5372 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005373 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005374 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005375 return skip;
5376}
5377
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005378bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5379 VkDeviceSize offset, VkBuffer countBuffer,
5380 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005381 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005382 bool skip = false;
5383
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005384 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005385 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5386 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5387 "), is not a multiple of 4.",
5388 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005389 }
5390
5391 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005392 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5393 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5394 "), is not a multiple of 4.",
5395 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005396 }
5397
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005398 return skip;
5399}
5400
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005401bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005402 const VkAllocationCallbacks *pAllocator,
5403 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005404 bool skip = false;
5405
5406 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5407 if (pCreateInfo != nullptr) {
5408 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5409 // VkQueryPipelineStatisticFlagBits values
5410 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5411 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005412 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5413 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5414 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5415 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005416 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005417 if (pCreateInfo->queryCount == 0) {
5418 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5419 "vkCreateQueryPool(): queryCount must be greater than zero.");
5420 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005421 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005422 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005423}
5424
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005425bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5426 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005427 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005428 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5429 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005430}
5431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005432void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005433 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5434 VkResult result) {
5435 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005436 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005437}
5438
Mike Schuchardt2df08912020-12-15 16:28:09 -08005439void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005440 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5441 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005442 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005443 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005444 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005445}
5446
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005447void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5448 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005449 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005450 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005451 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005452}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005453
Tony-LunarG3c287f62020-12-17 12:39:49 -07005454void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005455 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005456 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005457 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005458 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005459 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005460 }
5461 }
5462}
5463
5464void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005465 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005466 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005467 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5468 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5469 }
5470}
5471
5472void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005473 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005474 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005475 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5476 if (item->second == commandPool) {
5477 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005478 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005479 ++item;
5480 }
5481 }
5482}
5483
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005484bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005485 const VkAllocationCallbacks *pAllocator,
5486 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005487 bool skip = false;
5488
5489 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005490 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005491 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005492 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5493 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005494 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005495
5496 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005497 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005498 if (flags_info) {
5499 flags = flags_info->flags;
5500 }
5501
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005502 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005503 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005504 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005505 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5506 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005507 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005508 }
5509
5510#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005511 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005512#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005513 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5514 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005515#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005516 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005517#endif
5518
5519 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005520 skip |= LogError(
5521 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005522 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5523 }
5524 if (
5525#ifdef VK_USE_PLATFORM_WIN32_KHR
5526 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5527#endif
5528 (import_memory_fd && import_memory_fd->handleType) ||
5529#ifdef VK_USE_PLATFORM_ANDROID_KHR
5530 (import_memory_ahb && import_memory_ahb->buffer) ||
5531#endif
5532 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005533 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5534 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005535 }
5536 }
5537
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005538 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5539 if (export_memory) {
5540 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5541 if (export_memory_nv) {
5542 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5543 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5544 "VkExportMemoryAllocateInfoNV");
5545 }
5546#ifdef VK_USE_PLATFORM_WIN32_KHR
5547 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5548 if (export_memory_win32_nv) {
5549 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5550 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5551 "VkExportMemoryWin32HandleInfoNV");
5552 }
5553#endif
5554 }
5555
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005556 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005557 VkBool32 capture_replay = false;
5558 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005559 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005560 if (vulkan_12_features) {
5561 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5562 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5563 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005564 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005565 if (bda_features) {
5566 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5567 buffer_device_address = bda_features->bufferDeviceAddress;
5568 }
5569 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005570 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005571 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005572 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005573 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005574 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005575 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005576 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005577 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005578 }
5579 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005580 }
5581 return skip;
5582}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005583
Jason Macnak192fa0e2019-07-26 15:07:16 -07005584bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005585 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005586 bool skip = false;
5587
5588 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5589 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5590 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005591 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005592 } else {
5593 uint32_t vertex_component_size = 0;
5594 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5595 vertex_component_size = 4;
5596 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5597 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5598 vertex_component_size = 2;
5599 }
5600 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005601 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005602 }
5603 }
5604
5605 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5606 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005607 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005608 } else {
5609 uint32_t index_element_size = 0;
5610 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5611 index_element_size = 4;
5612 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5613 index_element_size = 2;
5614 }
5615 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005616 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005617 }
5618 }
5619 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5620 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005621 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005622 }
5623 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005624 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005625 }
5626 }
5627
5628 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005629 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005630 }
5631
5632 return skip;
5633}
5634
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005635bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5636 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005637 bool skip = false;
5638
5639 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005640 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005641 }
5642 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005643 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005644 }
5645
5646 return skip;
5647}
5648
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005649bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5650 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005651 bool skip = false;
5652 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005653 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005654 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005655 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005656 }
5657 return skip;
5658}
5659
5660bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005661 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005662 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005663 bool skip = false;
5664 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005665 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5666 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5667 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005668 }
5669 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005670 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5671 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5672 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005673 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005674 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5675 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5676 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5677 }
Jason Macnak5c954952019-07-09 15:46:12 -07005678 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5679 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005680 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5681 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5682 "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 -07005683 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005684 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005685 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005686 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5687 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005688 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5689 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005690 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005691 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005692 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5693 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5694 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005695 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005696 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005697 uint64_t total_triangle_count = 0;
5698 for (uint32_t i = 0; i < info.geometryCount; i++) {
5699 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005700
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005701 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005702
Jason Macnak5c954952019-07-09 15:46:12 -07005703 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5704 continue;
5705 }
5706 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5707 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005708 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005709 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5710 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5711 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005712 }
5713 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005714 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5715 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5716 for (uint32_t i = 1; i < info.geometryCount; i++) {
5717 const VkGeometryNV &geometry = info.pGeometries[i];
5718 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005719 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005720 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5721 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005722 "info.pGeometries[0].geometryType.",
5723 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005724 }
5725 }
5726 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005727 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5728 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5729 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5730 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5731 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5732 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5733 }
5734 }
5735 skip |=
5736 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005737 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005738 return skip;
5739}
5740
Ricardo Garciaa4935972019-02-21 17:43:18 +01005741bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5742 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005743 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005744 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005745 if (pCreateInfo) {
5746 if ((pCreateInfo->compactedSize != 0) &&
5747 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005748 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5749 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5750 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5751 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005752 }
Jason Macnak5c954952019-07-09 15:46:12 -07005753
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005754 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005755 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005756 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005757 return skip;
5758}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005759
Jeff Bolz5c801d12019-10-09 10:38:45 -05005760bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5761 const VkAccelerationStructureInfoNV *pInfo,
5762 VkBuffer instanceData, VkDeviceSize instanceOffset,
5763 VkBool32 update, VkAccelerationStructureNV dst,
5764 VkAccelerationStructureNV src, VkBuffer scratch,
5765 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005766 bool skip = false;
5767
5768 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005769 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005770 }
5771
5772 return skip;
5773}
5774
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005775bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5776 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5777 VkAccelerationStructureKHR *pAccelerationStructure) const {
5778 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005779 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005780 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005781 if (!acceleration_structure_features ||
5782 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5783 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5784 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5785 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005786 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005787 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5788 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005789 (acceleration_structure_features &&
5790 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005791 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005792 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5793 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5794 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5795 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005796 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005797 if (pCreateInfo->deviceAddress &&
5798 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5799 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5800 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5801 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5802 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005803 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5804 (acceleration_structure_features &&
5805 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5806 skip |= LogError(
5807 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5808 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5809 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5810 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005811 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5812 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005813 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5814 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005815 }
sourav parmar83c31b12020-05-06 12:30:54 -07005816 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005817 return skip;
5818}
5819
Jason Macnak5c954952019-07-09 15:46:12 -07005820bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5821 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005822 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005823 bool skip = false;
5824 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005825 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5826 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005827 }
5828 return skip;
5829}
5830
sourav parmarcd5fb182020-07-17 12:58:44 -07005831bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5832 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5833 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5834 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005835 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005836 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005837 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005838 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005839 }
5840 return skip;
5841}
5842
Peter Chen85366392019-05-14 15:20:11 -04005843bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5844 uint32_t createInfoCount,
5845 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5846 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005847 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005848 bool skip = false;
5849
5850 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005851 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5852 std::stringstream msg;
5853 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5854 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5855 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005856 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005857 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005858 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005859 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5860 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5861 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5862 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005863 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005864
5865 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005866 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005867 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5868 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5869 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5870 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5871 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5872 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5873 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5874 }
5875 }
5876
sourav parmarf4a78252020-04-10 13:04:21 -07005877 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5878 skip |=
5879 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5880 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5881 }
5882 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5883 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5884 skip |=
5885 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5886 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5887 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5888 }
5889 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5890 if (pCreateInfos[i].basePipelineIndex != -1) {
5891 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5892 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5893 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5894 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5895 "and pCreateInfos->basePipelineIndex is not -1.");
5896 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005897 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005898 skip |=
5899 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5900 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5901 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5902 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5903 "that element.");
5904 }
sourav parmarf4a78252020-04-10 13:04:21 -07005905 }
5906 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005907 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005908 skip |=
5909 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5910 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5911 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5912 "commands pCreateInfos parameter.");
5913 }
5914 } else {
5915 if (pCreateInfos[i].basePipelineIndex != -1) {
5916 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5917 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5918 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5919 }
5920 }
5921 }
5922 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5923 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5924 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5925 }
5926 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5927 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5928 "vkCreateRayTracingPipelinesNV: flags must not include "
5929 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5930 }
5931 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5932 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5933 "vkCreateRayTracingPipelinesNV: flags must not include "
5934 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5935 }
5936 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5937 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5938 "vkCreateRayTracingPipelinesNV: flags must not include "
5939 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5940 }
5941 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5942 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5943 "vkCreateRayTracingPipelinesNV: flags must not include "
5944 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5945 }
5946 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5947 skip |= LogError(
5948 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5949 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5950 }
5951 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5952 skip |= LogError(
5953 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5954 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5955 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005956 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5957 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5958 "vkCreateRayTracingPipelinesNV: flags must not include "
5959 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5960 }
5961 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5962 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5963 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5964 }
ziga-lunargdfffee42021-10-10 11:49:59 +02005965 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
5966 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
5967 "vkCreateRayTracingPipelinesNV: flags must not contain the "
5968 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
5969 }
Peter Chen85366392019-05-14 15:20:11 -04005970 }
5971
5972 return skip;
5973}
5974
sourav parmarcd5fb182020-07-17 12:58:44 -07005975bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5976 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5977 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005978 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005979 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005980 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5981 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5982 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005983 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005984 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005985 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5986 std::stringstream msg;
5987 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5988 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5989 &pCreateInfos[i].pStages[i]);
5990 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005991 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5992 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5993 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5994 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5995 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5996 }
5997 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5998 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5999 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
6000 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
6001 }
6002 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006003 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006004 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
6005 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07006006 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
6007 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
6008 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006009 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
6010 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
6011 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006012 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006013 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07006014 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
6015 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
6016 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
6017 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07006018 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07006019 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
6020 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
6021 }
6022 }
sourav parmarf4a78252020-04-10 13:04:21 -07006023 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006024 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
6025 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07006026 }
6027 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006028 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07006029 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07006030 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
6031 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006032 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006033 }
6034 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
6035 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
6036 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07006037 }
6038 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
6039 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
6040 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
6041 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
6042 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
6043 skip |= LogError(
6044 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07006045 "vkCreateRayTracingPipelinesKHR: If flags includes "
6046 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006047 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6048 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
6049 "must not be VK_SHADER_UNUSED_KHR");
6050 }
6051 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
6052 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
6053 skip |= LogError(
6054 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07006055 "vkCreateRayTracingPipelinesKHR: If flags includes "
6056 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07006057 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
6058 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
6059 "element must not be VK_SHADER_UNUSED_KHR");
6060 }
6061 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006062 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
6063 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
6064 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
6065 skip |= LogError(
6066 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
6067 "vkCreateRayTracingPipelinesKHR: If "
6068 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
6069 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
6070 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
6071 }
6072 }
sourav parmarf4a78252020-04-10 13:04:21 -07006073 }
6074 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
6075 if (pCreateInfos[i].basePipelineIndex != -1) {
6076 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
6077 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07006078 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07006079 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
6080 "and pCreateInfos->basePipelineIndex is not -1.");
6081 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006082 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07006083 skip |=
6084 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
6085 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
6086 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
6087 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
6088 "element.");
6089 }
sourav parmarf4a78252020-04-10 13:04:21 -07006090 }
6091 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04006092 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07006093 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07006094 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006095 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
6096 ") must be a valid into the calling"
6097 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07006098 pCreateInfos[i].basePipelineIndex, createInfoCount);
6099 }
6100 } else {
6101 if (pCreateInfos[i].basePipelineIndex != -1) {
6102 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006103 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006104 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6105 }
6106 }
6107 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006108 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6109 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6110 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6111 "vkCreateRayTracingPipelinesKHR: If flags includes "
6112 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6113 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006114 }
6115 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6116 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6117 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6118 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6119 "pLibraryInfo and pLibraryInterface must be NULL.");
6120 }
6121 if (pCreateInfos[i].pLibraryInfo) {
6122 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6123 if (pCreateInfos[i].stageCount == 0) {
6124 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6125 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6126 "stageCount must not be 0.");
6127 }
6128 if (pCreateInfos[i].groupCount == 0) {
6129 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6130 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6131 "groupCount must not be 0.");
6132 }
6133 } else {
6134 if (pCreateInfos[i].pLibraryInterface == NULL) {
6135 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6136 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6137 "is greater than 0, its "
6138 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006139 }
6140 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006141 }
6142 if (pCreateInfos[i].pLibraryInterface) {
6143 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6144 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6145 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6146 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6147 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6148 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006149 }
6150 if (deferredOperation != VK_NULL_HANDLE) {
6151 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6152 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6153 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6154 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006155 }
6156 }
ziga-lunargdea76582021-09-17 14:38:08 +02006157 if (pCreateInfos[i].pDynamicState) {
6158 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6159 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6160 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6161 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6162 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6163 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6164 }
6165 }
6166 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006167 }
6168
6169 return skip;
6170}
6171
Mike Schuchardt21638df2019-03-16 10:52:02 -07006172#ifdef VK_USE_PLATFORM_WIN32_KHR
6173bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6174 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006175 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006176 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006177 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006178 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006179 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006180 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006181 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006182 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006183 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006184 skip |=
6185 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006186 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006187 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6188 skip |= validate_struct_type(
6189 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6190 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6191 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6192 if (pSurfaceInfo != NULL) {
6193 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6194 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6195 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6196
6197 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6198 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6199 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6200 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006201 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6202 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006203
6204 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6205 }
6206 return skip;
6207}
6208#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006209
6210bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6211 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006212 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006213 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6214 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006215 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006216 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6217 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6218 }
6219 return skip;
6220}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006221
6222bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006223 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006224 bool skip = false;
6225
6226 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006227 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006228 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006229 }
6230
6231 return skip;
6232}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006233
6234bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006235 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006236 bool skip = false;
6237
6238 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006239 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6240 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006241 }
6242
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006243 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006244 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006245 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6246 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006247 }
6248
6249 return skip;
6250}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006251
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006252bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6253 uint32_t bindingCount, const VkBuffer *pBuffers,
6254 const VkDeviceSize *pOffsets) const {
6255 bool skip = false;
6256 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006257 skip |=
6258 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6259 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6260 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006261 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6262 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006263 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6264 ") must be less than "
6265 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006266 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6267 }
6268
Jeff Bolz165818a2020-05-08 11:19:03 -05006269 for (uint32_t i = 0; i < bindingCount; ++i) {
6270 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006271 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006272 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006273 skip |=
6274 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6275 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006276 } else {
6277 if (pOffsets[i] != 0) {
6278 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006279 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6280 "] is not 0",
6281 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006282 }
6283 }
6284 }
6285 }
6286
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006287 return skip;
6288}
6289
Mark Lobodzinski84988402019-09-11 15:27:30 -06006290bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006291 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006292 bool skip = false;
6293 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006294 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6295 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006296 }
6297 return skip;
6298}
6299
6300bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006301 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006302 bool skip = false;
6303 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006304 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6305 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006306 }
6307 return skip;
6308}
Petr Kraus3d720392019-11-13 02:52:39 +01006309
6310bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6311 VkSemaphore semaphore, VkFence fence,
6312 uint32_t *pImageIndex) const {
6313 bool skip = false;
6314
6315 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006316 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6317 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006318 }
6319
6320 return skip;
6321}
6322
6323bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6324 uint32_t *pImageIndex) const {
6325 bool skip = false;
6326
6327 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006328 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6329 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006330 }
6331
6332 return skip;
6333}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006334
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006335bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6336 uint32_t firstBinding, uint32_t bindingCount,
6337 const VkBuffer *pBuffers,
6338 const VkDeviceSize *pOffsets,
6339 const VkDeviceSize *pSizes) const {
6340 bool skip = false;
6341
6342 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6343 for (uint32_t i = 0; i < bindingCount; ++i) {
6344 if (pOffsets[i] & 3) {
6345 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6346 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6347 }
6348 }
6349
6350 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6351 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6352 "%s: The firstBinding(%" PRIu32
6353 ") index is greater than or equal to "
6354 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6355 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6356 }
6357
6358 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6359 skip |=
6360 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6361 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6362 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6363 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6364 }
6365
6366 for (uint32_t i = 0; i < bindingCount; ++i) {
6367 // pSizes is optional and may be nullptr.
6368 if (pSizes != nullptr) {
6369 if (pSizes[i] != VK_WHOLE_SIZE &&
6370 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6371 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6372 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6373 ") is not VK_WHOLE_SIZE and is greater than "
6374 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6375 cmd_name, i, pSizes[i]);
6376 }
6377 }
6378 }
6379
6380 return skip;
6381}
6382
6383bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6384 uint32_t firstCounterBuffer,
6385 uint32_t counterBufferCount,
6386 const VkBuffer *pCounterBuffers,
6387 const VkDeviceSize *pCounterBufferOffsets) const {
6388 bool skip = false;
6389
6390 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6391 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6392 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6393 "%s: The firstCounterBuffer(%" PRIu32
6394 ") index is greater than or equal to "
6395 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6396 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6397 }
6398
6399 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6400 skip |=
6401 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6402 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6403 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6404 cmd_name, firstCounterBuffer, counterBufferCount,
6405 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6406 }
6407
6408 return skip;
6409}
6410
6411bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6412 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6413 const VkBuffer *pCounterBuffers,
6414 const VkDeviceSize *pCounterBufferOffsets) const {
6415 bool skip = false;
6416
6417 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6418 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6419 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6420 "%s: The firstCounterBuffer(%" PRIu32
6421 ") index is greater than or equal to "
6422 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6423 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6424 }
6425
6426 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6427 skip |=
6428 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6429 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6430 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6431 cmd_name, firstCounterBuffer, counterBufferCount,
6432 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6433 }
6434
6435 return skip;
6436}
6437
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006438bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6439 uint32_t firstInstance, VkBuffer counterBuffer,
6440 VkDeviceSize counterBufferOffset,
6441 uint32_t counterOffset, uint32_t vertexStride) const {
6442 bool skip = false;
6443
6444 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006445 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6446 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6447 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6448 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006449 }
6450
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006451 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006452 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006453 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006454 }
6455
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006456 return skip;
6457}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006458
6459bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6460 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6461 const VkAllocationCallbacks *pAllocator,
6462 VkSamplerYcbcrConversion *pYcbcrConversion,
6463 const char *apiName) const {
6464 bool skip = false;
6465
6466 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006467 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006468 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006469 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006470 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6471 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006472 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006473 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006474 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006475
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006476#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006477 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006478 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006479#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006480 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006481#endif
6482
sfricke-samsung1a72f942020-07-25 12:09:18 -07006483 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006484
6485 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006486 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006487 const VkComponentMapping components = pCreateInfo->components;
6488 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6489 if (FormatIsXChromaSubsampled(format) == true) {
6490 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6491 skip |=
6492 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006493 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6494 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006495 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006496 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006497
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006498 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6499 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6500 skip |= LogError(
6501 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6502 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6503 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6504 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6505 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006506
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006507 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6508 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6509 skip |=
6510 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006511 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6512 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006513 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006514 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006515
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006516 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6517 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6518 skip |=
6519 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006520 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6521 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006522 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006523 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006524
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006525 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006526 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6527 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6528 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006529 skip |=
6530 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006531 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6532 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006533 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6534 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006535 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006536 }
6537
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006538 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6539 // Checks same VU multiple ways in order to give a more useful error message
6540 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6541 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6542 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6543 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6544 skip |= LogError(
6545 device, vuid,
6546 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6547 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6548 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6549 string_VkComponentSwizzle(components.b));
6550 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006551
sfricke-samsunged028b02021-09-06 23:14:51 -07006552 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6553 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006554 // 3 = no [a]
6555 // 2 = no [b,a]
6556 // 1 = no [g,b,a]
6557 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006558 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006559
sfricke-samsunged028b02021-09-06 23:14:51 -07006560 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6561 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006562 skip |= LogError(device, vuid,
6563 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6564 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6565 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6566 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006567 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006568 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6569 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6570 skip |= LogError(device, vuid,
6571 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6572 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6573 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6574 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6575 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006576 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006577 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6578 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6579 skip |= LogError(device, vuid,
6580 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6581 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6582 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6583 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6584 string_VkComponentSwizzle(components.b));
6585 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006586 }
6587 }
6588
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006589 return skip;
6590}
6591
6592bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6593 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6594 const VkAllocationCallbacks *pAllocator,
6595 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6596 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6597 "vkCreateSamplerYcbcrConversion");
6598}
6599
6600bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6601 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6602 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6603 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6604 "vkCreateSamplerYcbcrConversionKHR");
6605}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006606
6607bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6608 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6609 bool skip = false;
6610 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6611 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6612
6613 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006614 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6615 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6616 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6617 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6618 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006619 }
6620 return skip;
6621}
sourav parmara96ab1a2020-04-25 16:28:23 -07006622
6623bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006624 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006625 bool skip = false;
6626 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6627 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6628 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6629 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006630 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006631 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6632 skip |= LogError(
6633 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6634 "vkCopyAccelerationStructureToMemoryKHR: The "
6635 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6636 }
6637 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6638 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6639 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6640 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6641 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6642 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006643 return skip;
6644}
6645
6646bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6647 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6648 bool skip = false;
6649 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6650 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6651 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6652 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6653 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006654 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6655 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006656 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006657 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006658 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006659 return skip;
6660}
6661
6662bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6663 const char *api_name) const {
6664 bool skip = false;
6665 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6666 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6667 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6668 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6669 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6670 api_name);
6671 }
6672 return skip;
6673}
6674
6675bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006676 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006677 bool skip = false;
6678 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006679 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006680 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006681 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006682 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6683 "vkCopyAccelerationStructureKHR: The "
6684 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006685 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006686 return skip;
6687}
6688
6689bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6690 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6691 bool skip = false;
6692 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6693 return skip;
6694}
6695
6696bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006697 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006698 bool skip = false;
6699 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006700 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006701 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6702 }
6703 return skip;
6704}
6705
6706bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006707 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006708 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006709 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006710 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006711 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6712 skip |= LogError(
6713 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6714 "vkCopyMemoryToAccelerationStructureKHR: The "
6715 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006716 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006717 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6718 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006719 return skip;
6720}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006721
sourav parmara96ab1a2020-04-25 16:28:23 -07006722bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6723 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6724 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006725 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006726 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6727 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006728 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006729 pInfo->src.deviceAddress);
6730 }
sourav parmar83c31b12020-05-06 12:30:54 -07006731 return skip;
6732}
6733bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6734 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6735 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6736 bool skip = false;
6737 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6738 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6739 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6740 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6741 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6742 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6743 }
6744 return skip;
6745}
6746bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6747 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6748 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6749 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006750 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006751 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6752 skip |= LogError(
6753 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6754 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6755 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6756 }
sourav parmar83c31b12020-05-06 12:30:54 -07006757 if (dataSize < accelerationStructureCount * stride) {
6758 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6759 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006760 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006761 dataSize, accelerationStructureCount, stride);
6762 }
6763 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6764 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6765 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6766 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6767 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6768 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6769 }
6770 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6771 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6772 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6773 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6774 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6775 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6776 stride);
6777 }
6778 }
6779 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6780 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6781 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6782 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6783 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6784 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6785 stride);
6786 }
6787 }
sourav parmar83c31b12020-05-06 12:30:54 -07006788 return skip;
6789}
6790bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6791 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6792 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006793 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006794 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6795 skip |= LogError(
6796 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6797 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6798 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006799 }
6800 return skip;
6801}
6802
6803bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006804 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6805 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6806 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6807 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006808 uint32_t width, uint32_t height, uint32_t depth) const {
6809 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006810 // RayGen
6811 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6812 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6813 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006814 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006815 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6816 0) {
6817 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6818 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6819 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6820 }
6821 // Callable
6822 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6823 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6824 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6825 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006826 }
6827 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6828 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6829 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006830 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6831 }
6832 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6833 0) {
6834 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6835 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6836 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006837 }
6838 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006839 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6840 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6841 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6842 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006843 }
6844 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6845 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006846 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6847 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006848 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006849 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6850 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6851 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6852 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6853 }
sourav parmar83c31b12020-05-06 12:30:54 -07006854 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006855 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6856 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6857 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6858 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006859 }
6860 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6861 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6862 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006863 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6864 }
6865 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6866 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6867 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6868 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6869 }
6870 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6871 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6872 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6873 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6874 }
6875 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6876 skip |=
6877 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6878 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6879 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006880 }
6881
sourav parmarcd5fb182020-07-17 12:58:44 -07006882 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6883 skip |=
6884 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6885 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6886 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6887 }
6888
6889 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6890 skip |=
6891 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6892 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6893 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006894 }
6895 return skip;
6896}
6897
sourav parmarcd5fb182020-07-17 12:58:44 -07006898bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6899 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6900 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6901 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006902 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006903 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006904 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6905 skip |= LogError(
6906 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6907 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6908 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006909 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006910 // RayGen
6911 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6912 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6913 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006914 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006915 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6916 0) {
6917 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6918 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6919 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6920 }
6921 // Callabe
6922 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6923 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6924 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6925 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006926 }
6927 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6928 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006929 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6930 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6931 }
6932 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6933 0) {
6934 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6935 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6936 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006937 }
6938 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006939 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6940 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6941 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6942 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006943 }
6944 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6945 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006946 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6947 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006948 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006949 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6950 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6951 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6952 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6953 }
sourav parmar83c31b12020-05-06 12:30:54 -07006954 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006955 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6956 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6957 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6958 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006959 }
6960 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6961 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006962 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6963 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6964 }
6965 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6966 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6967 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6968 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006969 }
6970
sourav parmarcd5fb182020-07-17 12:58:44 -07006971 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6972 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6973 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006974 }
6975 return skip;
6976}
6977bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6978 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6979 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6980 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6981 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6982 uint32_t width, uint32_t height, uint32_t depth) const {
6983 bool skip = false;
6984 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6985 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6986 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6987 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6988 }
6989 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6990 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6991 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6992 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6993 }
6994 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6995 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6996 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6997 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6998 }
6999
7000 // hitShader
7001 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7002 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
7003 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
7004 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7005 }
7006 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7007 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
7008 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
7009 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7010 }
7011 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7012 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
7013 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
7014 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7015 }
7016
7017 // missShader
7018 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7019 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
7020 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
7021 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7022 }
7023 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
7024 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
7025 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
7026 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
7027 }
7028 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
7029 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
7030 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
7031 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
7032 }
7033
7034 // raygenShader
7035 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
7036 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
7037 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07007038 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
7039 }
7040 if (width > device_limits.maxComputeWorkGroupCount[0]) {
7041 skip |=
7042 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
7043 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
7044 }
7045 if (height > device_limits.maxComputeWorkGroupCount[1]) {
7046 skip |=
7047 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
7048 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
7049 }
7050 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
7051 skip |=
7052 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
7053 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07007054 }
7055 return skip;
7056}
7057
sourav parmar83c31b12020-05-06 12:30:54 -07007058bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07007059 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
7060 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07007061 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007062 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
7063 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07007064 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
7065 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007066 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07007067 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
7068 }
7069 return skip;
7070}
7071
Piers Daniell39842ee2020-07-10 16:42:33 -06007072bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
7073 const VkViewport *pViewports) const {
7074 bool skip = false;
7075
7076 if (!physical_device_features.multiViewport) {
7077 if (viewportCount != 1) {
7078 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
7079 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
7080 ") is not 1.",
7081 viewportCount);
7082 }
7083 } else { // multiViewport enabled
7084 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
7085 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
7086 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
7087 ") must "
7088 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
7089 viewportCount, device_limits.maxViewports);
7090 }
7091 }
7092
7093 if (pViewports) {
7094 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
7095 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
7096 const char *fn_name = "vkCmdSetViewportWithCountEXT";
7097 skip |= manual_PreCallValidateViewport(
7098 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
7099 }
7100 }
7101
7102 return skip;
7103}
7104
7105bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7106 const VkRect2D *pScissors) const {
7107 bool skip = false;
7108
7109 if (!physical_device_features.multiViewport) {
7110 if (scissorCount != 1) {
7111 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
7112 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7113 ") must "
7114 "be 1 when the multiViewport feature is disabled.",
7115 scissorCount);
7116 }
7117 } else { // multiViewport enabled
7118 if (scissorCount == 0) {
7119 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7120 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7121 ") must "
7122 "be great than zero.",
7123 scissorCount);
7124 } else if (scissorCount > device_limits.maxViewports) {
7125 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7126 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7127 ") must "
7128 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
7129 scissorCount, device_limits.maxViewports);
7130 }
7131 }
7132
7133 if (pScissors) {
7134 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7135 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7136
7137 if (scissor.offset.x < 0) {
7138 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7139 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
7140 scissor.offset.x);
7141 }
7142
7143 if (scissor.offset.y < 0) {
7144 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7145 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
7146 scissor.offset.y);
7147 }
7148
7149 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7150 if (x_sum > INT32_MAX) {
7151 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
7152 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7153 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7154 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
7155 }
7156
7157 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7158 if (y_sum > INT32_MAX) {
7159 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
7160 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7161 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7162 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7163 }
7164 }
7165 }
7166
7167 return skip;
7168}
7169
7170bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7171 uint32_t bindingCount, const VkBuffer *pBuffers,
7172 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7173 const VkDeviceSize *pStrides) const {
7174 bool skip = false;
7175 if (firstBinding >= device_limits.maxVertexInputBindings) {
7176 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007177 "vkCmdBindVertexBuffers2EXT() firstBinding (%" PRIu32
7178 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007179 firstBinding, device_limits.maxVertexInputBindings);
7180 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7181 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007182 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7183 ") must be less than "
7184 "maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007185 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7186 }
7187
7188 for (uint32_t i = 0; i < bindingCount; ++i) {
7189 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007190 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06007191 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007192 skip |= LogError(
7193 commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
7194 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007195 } else {
7196 if (pOffsets[i] != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007197 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
7198 "vkCmdBindVertexBuffers2EXT() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
7199 "] is not 0",
7200 i, i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007201 }
7202 }
7203 }
7204 if (pStrides) {
7205 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007206 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
7207 "vkCmdBindVertexBuffers2EXT() pStrides[%" PRIu32 "] (%" PRIu64
7208 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7209 i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007210 }
7211 }
7212 }
7213
7214 return skip;
7215}
sourav parmarcd5fb182020-07-17 12:58:44 -07007216
7217bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7218 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7219 bool skip = false;
7220 for (uint32_t i = 0; i < infoCount; ++i) {
7221 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7222 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7223 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7224 }
7225 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7226 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7227 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7228 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7229 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7230 api_name);
7231 }
7232 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7233 skip |=
7234 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7235 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7236 }
7237 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7238 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7239 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7240 }
7241 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7242 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7243 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7244 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7245 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7246 api_name);
7247 }
7248 if (pInfos[i].pGeometries) {
7249 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7250 skip |= validate_ranged_enum(
7251 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7252 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7253 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7254 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007255 skip |= validate_struct_type(
7256 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7257 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7258 &(pInfos[i].pGeometries[j].geometry.triangles),
7259 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7260 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7261 skip |= validate_struct_pnext(
7262 api_name,
7263 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7264 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7265 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7266 skip |=
7267 validate_ranged_enum(api_name,
7268 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7269 ParameterName::IndexVector{i, j}),
7270 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7271 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7272 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7273 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7274 &pInfos[i].pGeometries[j].geometry.triangles,
7275 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7276 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7277 skip |= validate_ranged_enum(
7278 api_name,
7279 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7280 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7281 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7282
7283 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7284 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7285 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7286 }
7287 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7288 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7289 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7290 skip |=
7291 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7292 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7293 api_name);
7294 }
7295 }
7296 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7297 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7298 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7299 &pInfos[i].pGeometries[j].geometry.instances,
7300 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7301 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7302 skip |= validate_struct_type(
7303 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7304 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7305 &(pInfos[i].pGeometries[j].geometry.instances),
7306 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7307 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7308 skip |= validate_struct_pnext(
7309 api_name,
7310 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7311 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7312 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7313
7314 skip |= validate_bool32(api_name,
7315 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7316 ParameterName::IndexVector{i, j}),
7317 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7318 }
7319 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7320 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7321 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7322 &pInfos[i].pGeometries[j].geometry.aabbs,
7323 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7324 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7325 skip |= validate_struct_type(
7326 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7327 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7328 &(pInfos[i].pGeometries[j].geometry.aabbs),
7329 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7330 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7331 skip |= validate_struct_pnext(
7332 api_name,
7333 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7334 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7335 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7336 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7337 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7338 "(%s):stride must be less than or equal to 2^32-1", api_name);
7339 }
7340 }
7341 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7342 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7343 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7344 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7345 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7346 api_name);
7347 }
7348 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7349 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7350 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7351 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7352 "of elements of"
7353 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7354 api_name);
7355 }
7356 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7357 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7358 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7359 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7360 api_name);
7361 }
7362 }
7363 }
7364 }
7365 if (pInfos[i].ppGeometries != NULL) {
7366 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7367 skip |= validate_ranged_enum(
7368 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7369 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7370 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7371 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007372 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7373 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7374 &pInfos[i].ppGeometries[j]->geometry.triangles,
7375 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7376 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7377 skip |= validate_struct_type(
7378 api_name,
7379 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7380 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7381 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7382 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7383 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7384 skip |= validate_struct_pnext(
7385 api_name,
7386 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7387 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7388 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7389 skip |= validate_ranged_enum(api_name,
7390 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7391 ParameterName::IndexVector{i, j}),
7392 "VkFormat", AllVkFormatEnums,
7393 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7394 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7395 skip |= validate_ranged_enum(api_name,
7396 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7397 ParameterName::IndexVector{i, j}),
7398 "VkIndexType", AllVkIndexTypeEnums,
7399 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7400 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7401 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7402 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7403 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7404 }
7405 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7406 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7407 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7408 skip |=
7409 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7410 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7411 api_name);
7412 }
7413 }
7414 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7415 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7416 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7417 &pInfos[i].ppGeometries[j]->geometry.instances,
7418 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7419 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7420 skip |= validate_struct_type(
7421 api_name,
7422 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7423 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7424 &(pInfos[i].ppGeometries[j]->geometry.instances),
7425 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7426 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7427 skip |= validate_struct_pnext(
7428 api_name,
7429 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7430 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7431 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7432 skip |= validate_bool32(api_name,
7433 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7434 ParameterName::IndexVector{i, j}),
7435 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7436 }
7437 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7438 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7439 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7440 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7441 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7442 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7443 skip |= validate_struct_type(
7444 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7445 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7446 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7447 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7448 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7449 skip |= validate_struct_pnext(
7450 api_name,
7451 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7452 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7453 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7454 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7455 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7456 "(%s):stride must be less than or equal to 2^32-1", api_name);
7457 }
7458 }
7459 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7460 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7461 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7462 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7463 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7464 api_name);
7465 }
7466 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7467 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7468 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7469 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7470 "of elements of"
7471 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7472 api_name);
7473 }
7474 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7475 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7476 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7477 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7478 api_name);
7479 }
7480 }
7481 }
7482 }
7483 }
7484 return skip;
7485}
7486bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7487 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7488 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7489 bool skip = false;
7490 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7491 for (uint32_t i = 0; i < infoCount; ++i) {
7492 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7493 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7494 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7495 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7496 "scratchData.deviceAddress member must be a multiple of "
7497 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7498 }
7499 for (uint32_t k = 0; k < infoCount; ++k) {
7500 if (i == k) continue;
7501 bool found = false;
7502 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007503 skip |=
7504 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7505 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7506 ") of pInfos must "
7507 "not be "
7508 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7509 ") of pInfos.",
7510 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007511 found = true;
7512 }
7513 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007514 skip |=
7515 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7516 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7517 ") of pInfos must "
7518 "not be "
7519 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7520 ") of pInfos.",
7521 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007522 found = true;
7523 }
7524 if (found) break;
7525 }
7526 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7527 if (pInfos[i].pGeometries) {
7528 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7529 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7530 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7531 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7532 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7533 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7534 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7535 }
7536 } else {
7537 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7538 skip |=
7539 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7540 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7541 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7542 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7543 }
7544 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007545 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007546 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7547 skip |= LogError(
7548 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7549 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7550 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7551 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007552 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7553 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007554 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7555 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7556 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7557 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7558 }
7559 }
7560 } else if (pInfos[i].ppGeometries) {
7561 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7562 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7563 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7564 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7565 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7566 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7567 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7568 }
7569 } else {
7570 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7571 skip |=
7572 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7573 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7574 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7575 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7576 }
7577 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007578 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007579 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7580 skip |= LogError(
7581 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7582 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7583 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7584 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007585 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7586 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007587 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7588 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7589 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7590 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7591 }
7592 }
7593 }
7594 }
7595 }
7596 return skip;
7597}
7598
7599bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7600 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7601 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7602 const uint32_t *const *ppMaxPrimitiveCounts) const {
7603 bool skip = false;
7604 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7605 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007606 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007607 if (!ray_tracing_acceleration_structure_features ||
7608 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7609 skip |= LogError(
7610 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7611 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7612 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7613 }
7614 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007615 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7616 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7617 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7618 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7619 "scratchData.deviceAddress member must be a multiple of "
7620 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7621 }
7622 for (uint32_t k = 0; k < infoCount; ++k) {
7623 if (i == k) continue;
7624 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007625 skip |= LogError(
7626 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7627 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7628 ") "
7629 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7630 "any other element [%" PRIu32 ") of pInfos.",
7631 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007632 break;
7633 }
7634 }
7635 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7636 if (pInfos[i].pGeometries) {
7637 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7638 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7639 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7640 skip |= LogError(
7641 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7642 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7643 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7644 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7645 }
7646 } else {
7647 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7648 skip |= LogError(
7649 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7650 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7651 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7652 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7653 }
7654 }
7655 }
7656 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7657 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7658 skip |= LogError(
7659 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7660 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7661 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7662 }
7663 }
7664 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7665 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7666 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7667 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7668 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7669 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7670 }
7671 }
7672 } else if (pInfos[i].ppGeometries) {
7673 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7674 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7675 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7676 skip |= LogError(
7677 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7678 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7679 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7680 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7681 }
7682 } else {
7683 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7684 skip |= LogError(
7685 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7686 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7687 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7688 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7689 }
7690 }
7691 }
7692 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7693 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7694 skip |= LogError(
7695 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7696 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7697 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7698 }
7699 }
7700 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7701 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7702 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7703 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7704 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7705 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7706 }
7707 }
7708 }
7709 }
7710 }
7711 return skip;
7712}
7713
7714bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7715 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7716 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7717 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7718 bool skip = false;
7719 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7720 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007721 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007722 if (!ray_tracing_acceleration_structure_features ||
7723 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7724 skip |=
7725 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7726 "vkBuildAccelerationStructuresKHR: The "
7727 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7728 }
7729 for (uint32_t i = 0; i < infoCount; ++i) {
7730 for (uint32_t j = 0; j < infoCount; ++j) {
7731 if (i == j) continue;
7732 bool found = false;
7733 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007734 skip |=
7735 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7736 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7737 ") of pInfos must "
7738 "not be "
7739 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7740 ") of pInfos.",
7741 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007742 found = true;
7743 }
7744 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007745 skip |=
7746 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7747 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7748 ") of pInfos must "
7749 "not be "
7750 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7751 ") of pInfos.",
7752 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007753 found = true;
7754 }
7755 if (found) break;
7756 }
7757 }
7758 return skip;
7759}
7760
7761bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7762 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7763 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7764 bool skip = false;
7765 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7766 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007767 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7768 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007769 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7770 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7771 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7772 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01007773 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
7774 }
7775 if (pBuildInfo != nullptr) {
7776 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
7777 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
7778 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
7779 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
7780 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007781 }
7782 return skip;
7783}
sfricke-samsungecafb192021-01-17 08:21:14 -08007784
7785bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7786 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7787 const VkAllocationCallbacks *pAllocator,
7788 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7789 bool skip = false;
7790 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7791 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7792 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7793 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7794 }
7795 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007796}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007797
7798bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7799 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7800 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7801 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7802 bool skip = false;
7803 const auto *vertex_input_dynamic_state_features =
7804 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7805 const auto *vertex_attribute_divisor_features =
7806 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7807
7808 // VUID-vkCmdSetVertexInputEXT-None-04790
7809 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7810 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7811 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7812 }
7813
7814 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7815 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7816 skip |=
7817 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7818 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7819 }
7820
7821 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7822 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7823 skip |= LogError(
7824 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7825 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7826 }
7827
7828 // VUID-vkCmdSetVertexInputEXT-binding-04793
7829 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7830 bool binding_found = false;
7831 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7832 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7833 binding_found = true;
7834 break;
7835 }
7836 }
7837 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007838 skip |= LogError(
7839 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7840 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007841 }
7842 }
7843
7844 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7845 if (vertexBindingDescriptionCount > 1) {
7846 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7847 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7848 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7849 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7850 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007851 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7852 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007853 }
7854 }
7855 }
7856 }
7857
7858 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7859 if (vertexAttributeDescriptionCount > 1) {
7860 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7861 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7862 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7863 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7864 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007865 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7866 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007867 }
7868 }
7869 }
7870 }
7871
7872 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7873 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7874 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007875 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7876 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7877 "].binding is greater than maxVertexInputBindings",
7878 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007879 }
7880
7881 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7882 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007883 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7884 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7885 "].stride is greater than maxVertexInputBindingStride",
7886 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007887 }
7888
7889 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7890 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7891 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7892 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007893 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7894 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007895 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7896 binding);
7897 }
7898
7899 if (pVertexBindingDescriptions[binding].divisor > 1) {
7900 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7901 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7902 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007903 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7904 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007905 "vertexAttributeInstanceRateDivisor is not enabled",
7906 binding);
7907 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007908 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007909 if (pVertexBindingDescriptions[binding].divisor >
7910 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007911 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
7912 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7913 "].divisor is greater than maxVertexAttribDivisor",
7914 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007915 }
7916
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007917 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007918 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007919 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
7920 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7921 "].divisor is greater than 1 but inputRate "
7922 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7923 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007924 }
7925 }
7926 }
7927 }
7928
7929 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007930 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007931 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007932 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
7933 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7934 "].location is greater than maxVertexInputAttributes",
7935 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007936 }
7937
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007938 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007939 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007940 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
7941 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7942 "].binding is greater than maxVertexInputBindings",
7943 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007944 }
7945
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007946 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007947 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007948 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
7949 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7950 "].offset is greater than maxVertexInputAttributeOffset",
7951 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007952 }
7953
7954 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7955 VkFormatProperties properties;
7956 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7957 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7958 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007959 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7960 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007961 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7962 attribute);
7963 }
7964 }
7965
7966 return skip;
7967}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007968
7969bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7970 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7971 const void *pValues) const {
7972 bool skip = false;
7973 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7974 // Check that offset + size don't exceed the max.
7975 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7976 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007977 skip |=
7978 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7979 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
7980 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007981 }
7982 if (size > max_push_constants_size - offset) {
7983 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007984 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
7985 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07007986 offset, size, max_push_constants_size);
7987 }
7988
7989 // size needs to be non-zero and a multiple of 4.
7990 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007991 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
7992 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007993 }
7994
7995 // offset needs to be a multiple of 4.
7996 if ((offset & 0x3) != 0) {
7997 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007998 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007999 }
8000 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06008001}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02008002
8003bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
8004 uint32_t srcCacheCount,
8005 const VkPipelineCache *pSrcCaches) const {
8006 bool skip = false;
8007 if (pSrcCaches) {
8008 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
8009 if (pSrcCaches[index0] == dstCache) {
8010 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
8011 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
8012 report_data->FormatHandle(dstCache).c_str());
8013 break;
8014 }
8015 }
8016 }
8017 return skip;
8018}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008019
8020bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
8021 VkImageLayout imageLayout, const VkClearColorValue *pColor,
8022 uint32_t rangeCount,
8023 const VkImageSubresourceRange *pRanges) const {
8024 bool skip = false;
8025 if (!pColor) {
8026 skip |=
8027 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
8028 }
8029 return skip;
8030}
8031
8032bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
8033 const VkRenderPassBeginInfo *const rp_begin) const {
8034 bool skip = false;
8035 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
8036 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
8037 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02008038 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06008039 func_name, rp_begin->clearValueCount);
8040 }
8041 return skip;
8042}
8043
8044bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8045 VkSubpassContents) const {
8046 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
8047 return skip;
8048}
8049
8050bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
8051 const VkRenderPassBeginInfo *pRenderPassBegin,
8052 const VkSubpassBeginInfo *) const {
8053 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
8054 return skip;
8055}
8056
8057bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
8058 const VkSubpassBeginInfo *) const {
8059 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
8060 return skip;
8061}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02008062
8063bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
8064 uint32_t firstDiscardRectangle,
8065 uint32_t discardRectangleCount,
8066 const VkRect2D *pDiscardRectangles) const {
8067 bool skip = false;
8068
8069 if (pDiscardRectangles) {
8070 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
8071 const int64_t x_sum =
8072 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
8073 if (x_sum > std::numeric_limits<int32_t>::max()) {
8074 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
8075 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8076 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8077 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
8078 }
8079
8080 const int64_t y_sum =
8081 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
8082 if (y_sum > std::numeric_limits<int32_t>::max()) {
8083 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
8084 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
8085 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
8086 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
8087 }
8088 }
8089 }
8090
8091 return skip;
8092}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02008093
8094bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
8095 uint32_t queryCount, size_t dataSize, void *pData,
8096 VkDeviceSize stride, VkQueryResultFlags flags) const {
8097 bool skip = false;
8098
8099 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
8100 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8101 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8102 }
8103
8104 return skip;
8105}
ziga-lunargcf340c42021-08-19 00:13:38 +02008106
8107bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8108 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8109 bool skip = false;
8110
8111 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8112 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8113 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8114 ") is not a multiple of 4.",
8115 pConditionalRenderingBegin->offset);
8116 }
8117
8118 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008119}