blob: d661c5e16a9fa47285d335c774b97cf4f299fb72 [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(
464 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-04476",
465 "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(
508 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
509 "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)) {
514 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
515 "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(
522 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
523 "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(
529 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
530 "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 |=
537 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
538 "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,
Jeff Bolz3e71f782018-08-29 23:15:45 -05002363 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002364 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002365 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01002366 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05002367 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05002368 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
2369 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002370 viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info),
2371 allowed_structs_vk_pipeline_viewport_state_create_info, 65,
2372 "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
sfricke-samsung32a27362020-02-28 09:06:42 -08002373 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002374
2375 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002376 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002377 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002378 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002379
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002380 auto exclusive_scissor_struct =
2381 LvlFindInChain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2382 auto shading_rate_image_struct =
2383 LvlFindInChain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
2384 auto coarse_sample_order_struct =
2385 LvlFindInChain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01002386 const auto vp_swizzle_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002387 LvlFindInChain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002388 const auto vp_w_scaling_struct =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002389 LvlFindInChain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002390
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002391 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002392 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002393 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2394 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2395 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2396 ") is not 1.",
2397 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002398 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002399
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06002400 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002401 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2402 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2403 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2404 ") is not 1.",
2405 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002406 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002407
Dave Houlton142c4cb2018-10-17 15:04:41 -06002408 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2409 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002410 skip |= LogError(
2411 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2412 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2413 "disabled, but pCreateInfos[%" PRIu32
2414 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2415 ") is not 1.",
2416 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002417 }
2418
Jeff Bolz9af91c52018-09-01 21:53:57 -05002419 if (shading_rate_image_struct &&
2420 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002421 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2422 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2423 "disabled, but pCreateInfos[%" PRIu32
2424 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2425 ") is neither 0 nor 1.",
2426 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002427 }
2428
Petr Krausa6103552017-11-16 21:21:58 +01002429 } else { // multiViewport enabled
2430 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002431 if (!has_dynamic_viewport_with_count) {
2432 skip |= LogError(
2433 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2434 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2435 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002436 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002437 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2438 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2439 "].pViewportState->viewportCount (=%" PRIu32
2440 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2441 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002442 } else if (has_dynamic_viewport_with_count) {
2443 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2444 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2445 "].pViewportState->viewportCount (=%" PRIu32
2446 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2447 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002448 }
Petr Krausa6103552017-11-16 21:21:58 +01002449
2450 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002451 if (!has_dynamic_scissor_with_count) {
2452 skip |= LogError(
2453 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2454 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2455 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002456 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002457 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2458 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2459 "].pViewportState->scissorCount (=%" PRIu32
2460 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2461 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002462 } else if (has_dynamic_scissor_with_count) {
2463 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2464 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2465 "].pViewportState->scissorCount (=%" PRIu32
2466 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2467 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002468 }
2469 }
2470
ziga-lunarg845883b2021-07-14 15:05:00 +02002471 if (!has_dynamic_scissor && viewport_state.pScissors) {
2472 for (uint32_t scissor_i = 0; scissor_i < viewport_state.scissorCount; ++scissor_i) {
2473 const auto &scissor = viewport_state.pScissors[scissor_i];
ziga-lunarga77dc802021-07-15 13:19:06 +02002474
2475 if (scissor.offset.x < 0) {
2476 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2477 "vkCreateGraphicsPipelines: offset.x (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2478 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2479 scissor.offset.x, i, scissor_i);
2480 }
2481
2482 if (scissor.offset.y < 0) {
2483 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-x-02821",
2484 "vkCreateGraphicsPipelines: offset.y (=%" PRIi32 ") of pCreateInfos[%" PRIu32
2485 "].pViewportState->pScissors[%" PRIu32 "] is negative.",
2486 scissor.offset.y, i, scissor_i);
2487 }
2488
ziga-lunarg845883b2021-07-14 15:05:00 +02002489 const int64_t x_sum =
2490 static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2491 if (x_sum > std::numeric_limits<int32_t>::max()) {
2492 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02822",
2493 "vkCreateGraphicsPipelines: offset.x + extent.width (=%" PRIi32 " + %" PRIu32
2494 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2495 "] will overflow int32_t.",
2496 scissor.offset.x, scissor.extent.width, x_sum, i, scissor_i);
2497 }
ziga-lunarga77dc802021-07-15 13:19:06 +02002498
ziga-lunarg845883b2021-07-14 15:05:00 +02002499 const int64_t y_sum =
2500 static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2501 if (y_sum > std::numeric_limits<int32_t>::max()) {
2502 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-offset-02823",
2503 "vkCreateGraphicsPipelines: offset.y + extent.height (=%" PRIi32 " + %" PRIu32
2504 " = %" PRIi64 ") of pCreateInfos[%" PRIu32 "].pViewportState->pScissors[%" PRIu32
2505 "] will overflow int32_t.",
2506 scissor.offset.y, scissor.extent.height, y_sum, i, scissor_i);
2507 }
2508 }
2509 }
2510
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002511 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002512 skip |=
2513 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2514 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2515 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2516 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002517 }
2518
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002519 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002520 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2521 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2522 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2523 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2524 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002525 }
2526
Piers Daniell39842ee2020-07-10 16:42:33 -06002527 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2528 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002529 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2530 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2531 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2532 "].pViewportState->viewportCount (=%" PRIu32 ").",
2533 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002534 }
2535
Dave Houlton142c4cb2018-10-17 15:04:41 -06002536 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002537 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002538 skip |=
2539 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2540 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2541 ") must be zero or identical to pCreateInfos[%" PRIu32
2542 "].pViewportState->viewportCount (=%" PRIu32 ").",
2543 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002544 }
2545
Dave Houlton142c4cb2018-10-17 15:04:41 -06002546 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002547 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002548 skip |= LogError(
2549 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002550 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2551 "] "
2552 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2553 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2554 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002555 }
2556
Petr Krausa6103552017-11-16 21:21:58 +01002557 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002558 skip |= LogError(
2559 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002560 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2561 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002562 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2563 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002564 }
2565
2566 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002567 skip |= LogError(
2568 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002569 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2570 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002571 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2572 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002573 }
2574
Jeff Bolz3e71f782018-08-29 23:15:45 -05002575 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002576 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2577 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2578 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002579 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002580 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2581 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2582 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2583 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002584 }
2585
Jeff Bolz9af91c52018-09-01 21:53:57 -05002586 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002587 shading_rate_image_struct->viewportCount > 0 &&
2588 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002590 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002591 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002592 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2593 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002594 i, i);
2595 }
2596
Chris Mayer328d8212018-12-11 14:16:18 +01002597 if (vp_swizzle_struct) {
2598 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002599 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2600 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2601 " does "
2602 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2603 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002604 }
2605 }
2606
Petr Krausb3fcdb42018-01-09 22:09:09 +01002607 // validate the VkViewports
2608 if (!has_dynamic_viewport && viewport_state.pViewports) {
2609 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2610 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002611 const char *fn_name = "vkCreateGraphicsPipelines";
2612 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2613 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2614 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002615 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002616 }
2617 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002618
sfricke-samsung45996a42021-09-16 13:45:27 -07002619 if (has_dynamic_viewport_w_scaling_nv && !IsExtEnabled(device_extensions.vk_nv_clip_space_w_scaling)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002620 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2621 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2622 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2623 "VK_NV_clip_space_w_scaling extension is not enabled.",
2624 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002625 }
2626
sfricke-samsung45996a42021-09-16 13:45:27 -07002627 if (has_dynamic_discard_rectangle_ext && !IsExtEnabled(device_extensions.vk_ext_discard_rectangles)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002628 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2629 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2630 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2631 "VK_EXT_discard_rectangles extension is not enabled.",
2632 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002633 }
2634
sfricke-samsung45996a42021-09-16 13:45:27 -07002635 if (has_dynamic_sample_locations_ext && !IsExtEnabled(device_extensions.vk_ext_sample_locations)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002636 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2637 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2638 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2639 "VK_EXT_sample_locations extension is not enabled.",
2640 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002641 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002642
sfricke-samsung45996a42021-09-16 13:45:27 -07002643 if (has_dynamic_exclusive_scissor_nv && !IsExtEnabled(device_extensions.vk_nv_scissor_exclusive)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002644 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2645 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2646 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2647 "VK_NV_scissor_exclusive extension is not enabled.",
2648 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002649 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002650
2651 if (coarse_sample_order_struct &&
2652 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2653 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002654 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2655 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2656 "] "
2657 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2658 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2659 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002660 }
2661
2662 if (coarse_sample_order_struct) {
2663 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002664 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002665 }
2666 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002667
2668 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2669 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002670 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2671 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2672 "] "
2673 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2674 ") "
2675 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2676 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002677 }
2678 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002679 skip |= LogError(
2680 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002681 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2682 "] "
2683 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2684 i);
2685 }
2686 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687 }
2688
2689 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002690 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002691 "vkCreateGraphicsPipelines: if pCreateInfos[%" PRIu32
2692 "].pRasterizationState->rasterizerDiscardEnable "
2693 "is VK_FALSE, pCreateInfos[%" PRIu32 "].pMultisampleState must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002694 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002695 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002696 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002697 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002698 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2699 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002700 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002701 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002702 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002703 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002704 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002705 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002706 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002707 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2708 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002709
2710 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002711 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002712 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002713 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002714
2715 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002716 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002717 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2718 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2719
2720 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002721 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002722 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2723 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002724 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002725 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002726
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002727 skip |= validate_flags(
2728 "vkCreateGraphicsPipelines",
2729 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2730 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002731 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002732
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002734 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002735 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2736 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2737
2738 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002739 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002740 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2741 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2742
2743 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002744 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002745 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2746 "].pMultisampleState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002747 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2748 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002749 }
John Zulauf7acac592017-11-06 11:15:53 -07002750 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002751 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002752 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2753 "vkCreateGraphicsPipelines(): parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002754 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002755 i);
John Zulauf7acac592017-11-06 11:15:53 -07002756 }
2757 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2758 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2759 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002760 skip |= LogError(device,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002761
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002762 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
2763 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%" PRIu32
2764 "].pMultisampleState->minSampleShading.",
2765 i);
John Zulauf7acac592017-11-06 11:15:53 -07002766 }
2767 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002768
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002769 const auto *line_state =
2770 LvlFindInChain<VkPipelineRasterizationLineStateCreateInfoEXT>(pCreateInfos[i].pRasterizationState->pNext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002771
2772 if (line_state) {
2773 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2774 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2775 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2776 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002777 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2778 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002779 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002780 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002781 }
2782 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2783 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002784 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2785 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002786 "pCreateInfos[%" PRIu32 "].pMultisampleState->alphaToOneEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002787 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002788 }
2789 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2790 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002791 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2792 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002793 "pCreateInfos[%" PRIu32 "].pMultisampleState->sampleShadingEnable == VK_TRUE.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002794 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002795 }
2796 }
2797 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2798 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2799 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002800 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002801 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32 "] lineStippleFactor = %" PRIu32
2802 " must be in the "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002803 "range [1,256].",
2804 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002805 }
2806 }
2807 const auto *line_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07002808 LvlFindInChain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002809 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2810 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002811 skip |=
2812 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002813 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2814 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002815 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2816 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002817 }
2818 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2819 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002820 skip |=
2821 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002822 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2823 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002824 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2825 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002826 }
2827 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2828 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002829 skip |=
2830 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002831 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2832 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002833 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2834 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002835 }
2836 if (line_state->stippledLineEnable) {
2837 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2838 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002839 skip |=
2840 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002841 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2842 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002843 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2844 "stippledRectangularLines feature.",
2845 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002846 }
2847 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2848 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002849 skip |=
2850 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002851 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2852 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002853 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2854 "stippledBresenhamLines feature.",
2855 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002856 }
2857 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2858 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002859 skip |=
2860 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002861 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2862 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002863 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2864 "stippledSmoothLines feature.",
2865 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002866 }
2867 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
Malcolm Bechardfc509002021-11-17 21:57:28 -05002868 (!line_features || !line_features->stippledRectangularLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002869 skip |=
2870 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002871 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
2872 "] lineRasterizationMode = "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002873 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2874 "stippledRectangularLines and strictLines features.",
2875 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002876 }
2877 }
2878 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879 }
2880
Petr Krause91f7a12017-12-14 20:57:36 +01002881 bool uses_color_attachment = false;
2882 bool uses_depthstencil_attachment = false;
2883 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002884 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002885 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2886 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002887 const auto &subpasses_uses = subpasses_uses_it->second;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002888 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002889 uses_color_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002890 }
2891 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) {
Petr Krause91f7a12017-12-14 20:57:36 +01002892 uses_depthstencil_attachment = true;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002893 }
Petr Krause91f7a12017-12-14 20:57:36 +01002894 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002895 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002896 }
2897
2898 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002900 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002901 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002902 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002903 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904
2905 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002906 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002908 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909
2910 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002911 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002912 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2913 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2914
2915 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002916 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002917 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2918 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2919
2920 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002921 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002922 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2923 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002924 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002925
2926 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002927 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002928 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2929 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2930
2931 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002932 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002933 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2934 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2935
2936 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002937 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002938 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2939 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002940 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941
2942 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002943 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2945 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002946 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947
2948 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002949 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002950 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2951 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002952 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953
2954 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002955 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2957 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002958 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959
2960 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2963 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002964 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965
2966 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002967 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2969 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002970 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002971
2972 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002973 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002974 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2975 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002976 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002977
2978 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002979 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2981 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002982 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983
2984 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002985 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07002986 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
2987 "].pDepthStencilState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002988 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2989 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002990 }
2991 }
2992
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07002993 const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = {
ziga-lunarg8de09162021-08-05 15:21:33 +02002994 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT,
2995 VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT};
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002996
Petr Krause91f7a12017-12-14 20:57:36 +01002997 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002998 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2999 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
3000 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3001 pCreateInfos[i].pColorBlendState,
3002 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
3003 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
3004
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003006 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06003007 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
ziga-lunarg8de09162021-08-05 15:21:33 +02003008 "VkPipelineColorBlendAdvancedStateCreateInfoEXT, VkPipelineColorWriteCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003009 ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info),
3010 allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003011 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
3012 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003013
3014 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003015 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003016 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06003017 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003018
3019 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003020 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003021 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
3022 pCreateInfos[i].pColorBlendState->logicOpEnable);
3023
3024 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003025 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003026 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
3027 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00003028 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06003029 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003030
3031 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003032 for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount;
3033 ++attachment_index) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003034 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003035 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003036 ParameterName::IndexVector{i, attachment_index}),
3037 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003038
3039 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003040 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003042 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003043 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003044 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003045 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003046
3047 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003048 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003049 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003050 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003051 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003052 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003053 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003054
3055 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003056 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003057 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003058 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003059 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003060 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003061 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003062
3063 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003064 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003066 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003067 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003068 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003069 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003070
3071 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003072 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003073 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003074 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003075 "VkBlendFactor", AllVkBlendFactorEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003076 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06003077 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003078
3079 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003080 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003081 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003082 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003083 "VkBlendOp", AllVkBlendOpEnums,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003084 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06003085 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086
3087 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003088 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003089 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003090 ParameterName::IndexVector{i, attachment_index}),
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003091 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003092 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02003093 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
ziga-lunarga283d022021-08-04 18:35:23 +02003094
3095 if (phys_dev_ext_props.blend_operation_advanced_props.advancedBlendAllOperations == VK_FALSE) {
3096 bool invalid = false;
3097 switch (pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp) {
3098 case VK_BLEND_OP_ZERO_EXT:
3099 case VK_BLEND_OP_SRC_EXT:
3100 case VK_BLEND_OP_DST_EXT:
3101 case VK_BLEND_OP_SRC_OVER_EXT:
3102 case VK_BLEND_OP_DST_OVER_EXT:
3103 case VK_BLEND_OP_SRC_IN_EXT:
3104 case VK_BLEND_OP_DST_IN_EXT:
3105 case VK_BLEND_OP_SRC_OUT_EXT:
3106 case VK_BLEND_OP_DST_OUT_EXT:
3107 case VK_BLEND_OP_SRC_ATOP_EXT:
3108 case VK_BLEND_OP_DST_ATOP_EXT:
3109 case VK_BLEND_OP_XOR_EXT:
3110 case VK_BLEND_OP_INVERT_EXT:
3111 case VK_BLEND_OP_INVERT_RGB_EXT:
3112 case VK_BLEND_OP_LINEARDODGE_EXT:
3113 case VK_BLEND_OP_LINEARBURN_EXT:
3114 case VK_BLEND_OP_VIVIDLIGHT_EXT:
3115 case VK_BLEND_OP_LINEARLIGHT_EXT:
3116 case VK_BLEND_OP_PINLIGHT_EXT:
3117 case VK_BLEND_OP_HARDMIX_EXT:
3118 case VK_BLEND_OP_PLUS_EXT:
3119 case VK_BLEND_OP_PLUS_CLAMPED_EXT:
3120 case VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT:
3121 case VK_BLEND_OP_PLUS_DARKER_EXT:
3122 case VK_BLEND_OP_MINUS_EXT:
3123 case VK_BLEND_OP_MINUS_CLAMPED_EXT:
3124 case VK_BLEND_OP_CONTRAST_EXT:
3125 case VK_BLEND_OP_INVERT_OVG_EXT:
3126 case VK_BLEND_OP_RED_EXT:
3127 case VK_BLEND_OP_GREEN_EXT:
3128 case VK_BLEND_OP_BLUE_EXT:
3129 invalid = true;
3130 break;
3131 default:
3132 break;
3133 }
3134 if (invalid) {
3135 skip |= LogError(
3136 device, "VUID-VkPipelineColorBlendAttachmentState-advancedBlendAllOperations-01409",
3137 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
3138 "].pColorBlendState->pAttachments[%" PRIu32
3139 "].colorBlendOp (%s) is not valid when "
3140 "VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT::advancedBlendAllOperations is "
3141 "VK_FALSE",
3142 i, attachment_index,
3143 string_VkBlendOp(
3144 pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp));
3145 }
3146 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147 }
3148 }
3149
3150 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07003151 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003152 "vkCreateGraphicsPipelines: parameter pCreateInfos[%" PRIu32
3153 "].pColorBlendState->sType must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003154 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
3155 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003156 }
3157
3158 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
3159 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
3160 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003161 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003162 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06003163 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
3164 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003165 }
3166 }
3167 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003168
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003169 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3170 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
Petr Kraus9752aae2017-11-24 03:05:50 +01003171 if (pCreateInfos[i].basePipelineIndex != -1) {
3172 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003173 skip |=
3174 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003175 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3176 "]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003177 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003178 "and pCreateInfos->basePipelineIndex is not -1.",
3179 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003180 }
3181 }
3182
Petr Kraus9752aae2017-11-24 03:05:50 +01003183 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3184 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003185 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003186 "vkCreateGraphicsPipelines parameter, pCreateInfos[%" PRIu32
3187 "]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003188 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003189 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3190 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003192 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07003193 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003194 skip |=
3195 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003196 "vkCreateGraphicsPipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRId32
3197 ") must be a valid"
3198 "index into the pCreateInfos array, of size %" PRIu32 ".",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003199 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06003200 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003201 }
3202 }
3203
Petr Kraus9752aae2017-11-24 03:05:50 +01003204 if (pCreateInfos[i].pRasterizationState) {
sfricke-samsung45996a42021-09-16 13:45:27 -07003205 if (!IsExtEnabled(device_extensions.vk_nv_fill_rectangle)) {
Chris Mayer840b2c42019-08-22 18:12:22 +02003206 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
3207 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003208 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
3209 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
3210 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
3211 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02003212 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3213 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07003214 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003215 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003216 "pCreateInfos[%" PRIu32
3217 "]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003218 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3219 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003220 }
3221 } else {
3222 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
3223 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
3224 (physical_device_features.fillModeNonSolid == false)) {
3225 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003226 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
3227 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003228 "pCreateInfos[%" PRIu32
3229 "]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07003230 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
3231 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02003232 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233 }
Petr Kraus299ba622017-11-24 03:09:03 +01003234
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003235 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01003236 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003237 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
3238 "The line width state is static (pCreateInfos[%" PRIu32
3239 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
3240 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
3241 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
3242 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003243 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003244 }
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003245
3246 // Validate no flags not allowed are used
3247 if ((flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003248 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003249 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3250 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003251 "VK_PIPELINE_CREATE_DISPATCH_BASE.",
3252 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003253 }
3254 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsungad008902021-04-16 01:25:34 -07003255 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003256 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3257 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003258 "VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3259 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003260 }
3261 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3262 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03372",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003263 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3264 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003265 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3266 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003267 }
3268 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3269 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03373",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003270 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3271 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003272 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3273 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003274 }
3275 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3276 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03374",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003277 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3278 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003279 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3280 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003281 }
3282 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3283 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03375",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003284 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3285 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003286 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3287 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003288 }
3289 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3290 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03376",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003291 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3292 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003293 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3294 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003295 }
3296 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3297 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003298 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3299 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003300 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3301 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003302 }
3303 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3304 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03577",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003305 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3306 "]->flags (0x%x) must not include "
sfricke-samsungad008902021-04-16 01:25:34 -07003307 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3308 i, flags);
sfricke-samsung5ea45bd2021-01-23 02:38:36 -08003309 }
ziga-lunarg4bd42e42021-10-04 13:19:29 +02003310 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3311 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-04947",
3312 "vkCreateGraphicsPipelines(): pCreateInfos[%" PRIu32
3313 "]->flags (0x%x) must not include "
3314 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3315 i, flags);
3316 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003317 }
3318 }
3319
3320 return skip;
3321}
3322
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003323bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
3324 uint32_t createInfoCount,
3325 const VkComputePipelineCreateInfo *pCreateInfos,
3326 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003327 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003328 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003329 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003330 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003331 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06003332 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003333 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04003334 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003335 skip |=
3336 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
3337 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
3338 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
3339 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04003340 }
sfricke-samsungc5227152020-02-09 17:36:31 -08003341
3342 // Make sure compute stage is selected
3343 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003344 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003345 "vkCreateComputePipelines(): the pCreateInfo[%" PRIu32
3346 "].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003347 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08003348 }
sourav parmarcd5fb182020-07-17 12:58:44 -07003349
sfricke-samsungeb549012021-04-16 01:25:51 -07003350 const VkPipelineCreateFlags flags = pCreateInfos[i].flags;
3351 // Validate no flags not allowed are used
3352 if ((flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003353 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03364",
3354 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3355 "]->flags (0x%x) must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.",
3356 i, flags);
sfricke-samsungeb549012021-04-16 01:25:51 -07003357 }
3358 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) != 0) {
3359 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03365",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003360 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3361 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003362 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.",
3363 i, flags);
3364 }
3365 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) != 0) {
3366 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03366",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003367 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3368 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003369 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.",
3370 i, flags);
3371 }
3372 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) != 0) {
3373 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03367",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003374 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3375 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003376 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.",
3377 i, flags);
3378 }
3379 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) != 0) {
3380 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003381 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3382 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003383 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.",
3384 i, flags);
3385 }
3386 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) != 0) {
3387 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03369",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003388 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3389 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003390 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.",
3391 i, flags);
3392 }
3393 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) != 0) {
3394 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003395 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3396 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003397 "VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.",
3398 i, flags);
3399 }
3400 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) != 0) {
3401 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03576",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003402 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3403 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003404 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.",
3405 i, flags);
3406 }
ziga-lunargf51e65f2021-07-18 23:51:57 +02003407 if ((flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) != 0) {
3408 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-04945",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003409 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3410 "]->flags (0x%x) must not include "
ziga-lunargf51e65f2021-07-18 23:51:57 +02003411 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV.",
3412 i, flags);
3413 }
sfricke-samsungeb549012021-04-16 01:25:51 -07003414 if ((flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) != 0) {
3415 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-02874",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003416 "vkCreateComputePipelines(): pCreateInfos[%" PRIu32
3417 "]->flags (0x%x) must not include "
sfricke-samsungeb549012021-04-16 01:25:51 -07003418 "VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.",
3419 i, flags);
sourav parmarcd5fb182020-07-17 12:58:44 -07003420 }
ziga-lunarg065f2402021-07-22 11:56:05 +02003421 if (flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
3422 if (pCreateInfos[i].basePipelineIndex != -1) {
3423 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3424 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00699",
3425 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3426 "]->basePipelineHandle, must be VK_NULL_HANDLE if pCreateInfos->flags contains the "
3427 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and pCreateInfos->basePipelineIndex is not -1.",
3428 i);
3429 }
3430 }
3431
3432 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
3433 if (pCreateInfos[i].basePipelineIndex != -1) {
3434 skip |= LogError(
3435 device, "VUID-VkComputePipelineCreateInfo-flags-00700",
3436 "vkCreateComputePipelines parameter, pCreateInfos[%" PRIu32
3437 "]->basePipelineIndex, must be -1 if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT "
3438 "flag and pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
3439 i);
3440 }
3441 } else {
3442 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
3443 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-flags-00698",
3444 "vkCreateComputePipelines parameter pCreateInfos[%" PRIu32 "]->basePipelineIndex (%" PRIi32
3445 ") must be a valid index into the pCreateInfos array, of size %" PRIu32 ".",
3446 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
3447 }
3448 }
3449 }
ziga-lunargc6341372021-07-28 12:57:42 +02003450
3451 std::stringstream msg;
3452 msg << "pCreateInfos[%" << i << "].stage";
3453 ValidatePipelineShaderStageCreateInfo("vkCreateComputePipelines", msg.str().c_str(), &pCreateInfos[i].stage);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003454 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003455 return skip;
3456}
3457
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003458bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003459 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003460 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003461
3462 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003463 const auto &features = physical_device_features;
3464 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003465
John Zulauf71968502017-10-26 13:51:15 -06003466 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
3467 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003468 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
3469 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
3470 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
3471 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06003472 }
3473
3474 // Anistropy cannot be enabled in sampler unless enabled as a feature
3475 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003476 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
3477 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
3478 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06003479 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003480 }
John Zulauf71968502017-10-26 13:51:15 -06003481
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003482 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
3483 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003484 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
3485 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3486 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3487 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003488 }
3489 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003490 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
3491 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3492 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3493 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003494 }
3495 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003496 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
3497 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3498 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
3499 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003500 }
3501 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3502 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3503 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
3504 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003505 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
3506 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
3507 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
3508 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
3509 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3510 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003511 }
3512 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003513 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
3514 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
3515 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06003516 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003517 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003518 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
3519 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
3520 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07003521 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003522 }
3523
3524 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
3525 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003526 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
3527 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003528 const auto *sampler_reduction = LvlFindInChain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
sfricke-samsung85252fb2020-05-08 20:44:06 -07003529 if (sampler_reduction != nullptr) {
3530 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
3531 skip |= LogError(
3532 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
3533 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
3534 }
3535 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003536 }
3537
3538 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
3539 // valid VkBorderColor value
3540 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3541 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
3542 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003543 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
3544 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003545 }
3546
John Zulauf275805c2017-10-26 15:34:49 -06003547 // Checks for the IMG cubic filtering extension
sfricke-samsung45996a42021-09-16 13:45:27 -07003548 if (IsExtEnabled(device_extensions.vk_img_filter_cubic)) {
John Zulauf275805c2017-10-26 15:34:49 -06003549 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
3550 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003551 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
3552 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
3553 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06003554 }
3555 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003556
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003557 // Check for valid Lod range
3558 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003559 skip |=
3560 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
3561 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003562 }
3563
3564 // Check mipLodBias to device limit
3565 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003566 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
3567 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
3568 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08003569 }
3570
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003571 const auto *sampler_conversion = LvlFindInChain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003572 if (sampler_conversion != nullptr) {
3573 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3574 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3575 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
3576 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003577 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07003578 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07003579 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
3580 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
3581 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
3582 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
3583 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
3584 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
3585 }
3586 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02003587
3588 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
3589 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
3590 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
3591 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3592 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
3593 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
3594 }
3595 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
3596 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
3597 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3598 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
3599 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
3600 }
3601 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
3602 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
3603 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3604 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
3605 pCreateInfo->minLod, pCreateInfo->maxLod);
3606 }
3607 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3608 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
3609 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
3610 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
3611 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
3612 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3613 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
3614 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
3615 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
3616 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
3617 }
3618 if (pCreateInfo->anisotropyEnable) {
3619 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
3620 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3621 "pCreateInfo->anisotropyEnable must be VK_FALSE");
3622 }
3623 if (pCreateInfo->compareEnable) {
3624 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
3625 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3626 "pCreateInfo->compareEnable must be VK_FALSE");
3627 }
3628 if (pCreateInfo->unnormalizedCoordinates) {
3629 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
3630 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
3631 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
3632 }
3633 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003634
Piers Daniell833b9492021-11-20 11:47:10 -07003635 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
3636 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
3637 if (!IsExtEnabled(device_extensions.vk_ext_custom_border_color)) {
3638 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
3639 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
3640 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
3641 }
3642 auto custom_create_info = LvlFindInChain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
3643 if (!custom_create_info) {
3644 skip |= LogError(
3645 device, "VUID-VkSamplerCreateInfo-borderColor-04011",
3646 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
3647 "struct in pNext chain.\n",
3648 string_VkBorderColor(pCreateInfo->borderColor));
3649 } else {
3650 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
3651 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT &&
3652 !FormatIsSampledInt(custom_create_info->format)) ||
3653 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
3654 !FormatIsSampledFloat(custom_create_info->format)))) {
3655 skip |=
3656 LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
Tony-LunarG7337b312020-04-15 16:40:25 -06003657 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
3658 "whose type does not match\n",
3659 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
Piers Daniell833b9492021-11-20 11:47:10 -07003660 ;
3661 }
3662 }
3663 }
3664
3665 const auto *border_color_component_mapping =
3666 LvlFindInChain<VkSamplerBorderColorComponentMappingCreateInfoEXT>(pCreateInfo->pNext);
3667 if (border_color_component_mapping) {
3668 const auto *border_color_swizzle_features =
3669 LvlFindInChain<VkPhysicalDeviceBorderColorSwizzleFeaturesEXT>(device_createinfo_pnext);
3670 bool border_color_swizzle_features_enabled =
3671 border_color_swizzle_features && border_color_swizzle_features->borderColorSwizzle;
3672 if (!border_color_swizzle_features_enabled) {
3673 skip |= LogError(device, "VUID-VkSamplerBorderColorComponentMappingCreateInfoEXT-borderColorSwizzle-06437",
3674 "vkCreateSampler(): The borderColorSwizzle feature must be enabled to use "
3675 "VkPhysicalDeviceBorderColorSwizzleFeaturesEXT");
Tony-LunarG7337b312020-04-15 16:40:25 -06003676 }
3677 }
3678 }
3679
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003680 return skip;
3681}
3682
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003683bool StatelessValidation::ValidateMutableDescriptorTypeCreateInfo(const VkDescriptorSetLayoutCreateInfo &create_info,
3684 const VkMutableDescriptorTypeCreateInfoVALVE &mutable_create_info,
3685 const char *func_name) const {
3686 bool skip = false;
3687
3688 for (uint32_t i = 0; i < create_info.bindingCount; ++i) {
3689 uint32_t mutable_type_count = 0;
3690 if (mutable_create_info.mutableDescriptorTypeListCount > i) {
3691 mutable_type_count = mutable_create_info.pMutableDescriptorTypeLists[i].descriptorTypeCount;
3692 }
3693 if (create_info.pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3694 if (mutable_type_count == 0) {
3695 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04597",
3696 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3697 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE, but "
3698 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3699 "].descriptorTypeCount is 0.",
3700 func_name, i, i);
3701 }
3702 } else {
3703 if (mutable_type_count > 0) {
3704 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-descriptorTypeCount-04599",
3705 "%s: VkDescriptorSetLayoutCreateInfo::pBindings[%" PRIu32
3706 "].descriptorType is %s, but "
3707 "VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3708 "].descriptorTypeCount is not 0.",
3709 func_name, i, string_VkDescriptorType(create_info.pBindings[i].descriptorType), i);
3710 }
3711 }
3712 }
3713
3714 for (uint32_t j = 0; j < mutable_create_info.mutableDescriptorTypeListCount; ++j) {
3715 for (uint32_t k = 0; k < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
3716 switch (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]) {
3717 case VK_DESCRIPTOR_TYPE_MUTABLE_VALVE:
3718 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04600",
3719 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3720 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.",
3721 func_name, j, k);
3722 break;
3723 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
3724 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04601",
3725 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3726 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC.",
3727 func_name, j, k);
3728 break;
3729 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
3730 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04602",
3731 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3732 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC.",
3733 func_name, j, k);
3734 break;
3735 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT:
3736 skip |= LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04603",
3737 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3738 "].pDescriptorTypes[%" PRIu32 "] is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT.",
3739 func_name, j, k);
3740 break;
3741 default:
3742 break;
3743 }
3744 for (uint32_t l = k + 1; l < mutable_create_info.pMutableDescriptorTypeLists[j].descriptorTypeCount; ++l) {
3745 if (mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k] ==
3746 mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[l]) {
3747 skip |=
3748 LogError(device, "VUID-VkMutableDescriptorTypeListVALVE-pDescriptorTypes-04598",
3749 "%s: VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3750 "].pDescriptorTypes[%" PRIu32
3751 "] and VkMutableDescriptorTypeCreateInfoVALVE::pMutableDescriptorTypeLists[%" PRIu32
3752 "].pDescriptorTypes[%" PRIu32 "] are both %s.",
3753 func_name, j, k, j, l,
3754 string_VkDescriptorType(mutable_create_info.pMutableDescriptorTypeLists[j].pDescriptorTypes[k]));
3755 }
3756 }
3757 }
3758 }
3759
3760 return skip;
3761}
3762
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003763bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3764 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3765 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003766 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003767 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003768
ziga-lunargfc6896f2021-10-15 18:46:12 +02003769 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
3770 const auto *mutable_descriptor_type_features = LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
3771 bool mutable_descriptor_type_features_enabled =
3772 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
3773
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003774 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3775 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3776 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3777 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003778 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3779 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3780 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3781 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3782 ++descriptor_index) {
3783 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003784 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003785 "vkCreateDescriptorSetLayout: required parameter "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003786 "pCreateInfo->pBindings[%" PRIu32 "].pImmutableSamplers[%" PRIu32
3787 "] specified as VK_NULL_HANDLE",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003788 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003789 }
3790 }
3791 }
3792
3793 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3794 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3795 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003796 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003797 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3798 "].descriptorCount is not 0, "
3799 "pCreateInfo->pBindings[%" PRIu32
3800 "].stageFlags must be a valid combination of VkShaderStageFlagBits "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 "values.",
3802 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003803 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003804
3805 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3806 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3807 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003808 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3809 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%" PRIu32
3810 "].descriptorCount is not 0 and "
3811 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%" PRIu32
3812 "].stageFlags "
3813 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3814 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003815 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003816
3817 if (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3818 if (!mutable_descriptor_type) {
3819 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04593",
3820 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3821 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3822 "VkMutableDescriptorTypeCreateInfoVALVE is not included in the pNext chain.",
3823 i);
3824 }
3825 if (pCreateInfo->pBindings[i].pImmutableSamplers) {
3826 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-descriptorType-04594",
3827 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3828 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3829 "pImmutableSamplers is not NULL.",
3830 i);
3831 }
3832 if (!mutable_descriptor_type_features_enabled) {
3833 skip |= LogError(
3834 device, "VUID-VkDescriptorSetLayoutCreateInfo-mutableDescriptorType-04595",
3835 "vkCreateDescriptorSetLayout(): pCreateInfo->pBindings[%" PRIu32
3836 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE but "
3837 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.",
3838 i);
3839 }
3840 }
3841
3842 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR &&
3843 pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
3844 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04591",
3845 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3846 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, but pCreateInfo->pBindings[%" PRIu32
3847 "].descriptorType is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE.", i);
3848 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003849 }
3850 }
ziga-lunarg8a4d3192021-10-13 19:54:19 +02003851
3852 if (mutable_descriptor_type) {
3853 ValidateMutableDescriptorTypeCreateInfo(*pCreateInfo, *mutable_descriptor_type,
3854 "vkDescriptorSetLayoutCreateInfo");
3855 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003856 }
ziga-lunargfc6896f2021-10-15 18:46:12 +02003857 if (pCreateInfo) {
3858 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) &&
3859 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3860 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04590",
3861 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3862 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR and "
3863 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3864 }
3865 if ((pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT) &&
3866 (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE)) {
3867 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04592",
3868 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains both "
3869 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT and "
3870 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE.");
3871 }
3872 if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE &&
3873 !mutable_descriptor_type_features_enabled) {
3874 skip |= LogError(device, "VUID-VkDescriptorSetLayoutCreateInfo-flags-04596",
3875 "vkCreateDescriptorSetLayout(): pCreateInfo->flags contains "
3876 "VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE, but "
3877 "VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType feature is not enabled.");
3878 }
3879 }
3880
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003881 return skip;
3882}
3883
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003884bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3885 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003886 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003887 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3888 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3889 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003890 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3891 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003892}
3893
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003894bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3895 const VkWriteDescriptorSet *pDescriptorWrites,
3896 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003897 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003898
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003899 if (pDescriptorWrites != NULL) {
3900 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3901 // descriptorCount must be greater than 0
3902 if (pDescriptorWrites[i].descriptorCount == 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003903 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3904 "%s(): parameter pDescriptorWrites[%" PRIu32 "].descriptorCount must be greater than 0.",
3905 vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003906 }
3907
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003908 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3909 if (validateDstSet) {
3910 // dstSet must be a valid VkDescriptorSet handle
3911 skip |= validate_required_handle(vkCallingFunction,
3912 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3913 pDescriptorWrites[i].dstSet);
3914 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003915
3916 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3917 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3918 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3919 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3920 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3921 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3922 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003923 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3924 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003925 if (pDescriptorWrites[i].pImageInfo == nullptr) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003926 skip |=
3927 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3928 "%s(): if pDescriptorWrites[%" PRIu32
3929 "].descriptorType is "
3930 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3931 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3932 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%" PRIu32 "].pImageInfo must not be NULL.",
3933 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003934 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3935 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003936 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3937 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003938 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3939 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003940 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003941 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3942 ParameterName::IndexVector{i, descriptor_index}),
3943 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003944 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003945 }
3946 }
3947 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3948 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3949 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3950 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3951 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3952 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3953 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003954 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003955 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003956 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003957 "%s(): if pDescriptorWrites[%" PRIu32
3958 "].descriptorType is "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003959 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3960 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003961 "pDescriptorWrites[%" PRIu32 "].pBufferInfo must not be NULL.",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003962 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003963 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003964 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07003965 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05003966 if (robustness2_features && robustness2_features->nullDescriptor) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003967 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3968 ++descriptor_index) {
3969 if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE &&
3970 (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 ||
3971 pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003972 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003973 "%s(): if pDescriptorWrites[%" PRIu32
3974 "].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003975 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003976 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset,
3977 pDescriptorWrites[i].pBufferInfo[descriptor_index].range);
Jeff Bolz165818a2020-05-08 11:19:03 -05003978 }
3979 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003980 }
3981 }
3982 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3983 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003984 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003985 }
3986
3987 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3988 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003989 VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003990 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3991 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003992 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003993 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003994 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07003995 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003996 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07003997 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003998 }
3999 }
4000 }
4001 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
4002 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004003 VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004004 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
4005 if (pDescriptorWrites[i].pBufferInfo != NULL) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004006 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06004007 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004008 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004009 "%s(): pDescriptorWrites[%" PRIu32 "].pBufferInfo[%" PRIu32 "].offset (0x%" PRIxLEAST64
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004010 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004011 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004012 }
4013 }
4014 }
4015 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004016 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
4017 // or VkWriteDescriptorSetInlineUniformBlockEX
sourav parmarbcee7512020-12-28 14:34:49 -08004018 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004019 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004020 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4021 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
4022 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
4023 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004024 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004025 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4026 pDescriptorWrites[i].descriptorCount);
4027 }
4028 // further checks only if we have right structtype
4029 if (pnext_struct) {
4030 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4031 skip |= LogError(
4032 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004033 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4034 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004035 ".",
4036 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07004037 }
sourav parmarbcee7512020-12-28 14:34:49 -08004038 if (pnext_struct->accelerationStructureCount == 0) {
4039 skip |= LogError(device,
4040 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004041 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004042 }
4043 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004044 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004045 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4046 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4047 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4048 skip |= LogError(device,
4049 "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580",
4050 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004051 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004052 }
4053 }
4054 }
sourav parmarbcee7512020-12-28 14:34:49 -08004055 }
4056 } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004057 const auto *pnext_struct = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext);
sourav parmarbcee7512020-12-28 14:34:49 -08004058 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
4059 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817",
4060 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext"
4061 "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004062 "accelerationStructureCount %" PRIu32 " member equals descriptorCount %" PRIu32 ".",
sourav parmarbcee7512020-12-28 14:34:49 -08004063 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
4064 pDescriptorWrites[i].descriptorCount);
4065 }
4066 // further checks only if we have right structtype
4067 if (pnext_struct) {
4068 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
4069 skip |= LogError(
4070 device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004071 "%s(): accelerationStructureCount %" PRIu32 " must be equal to descriptorCount %" PRIu32
4072 " in the extended structure "
sourav parmarbcee7512020-12-28 14:34:49 -08004073 ".",
4074 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmarcd5fb182020-07-17 12:58:44 -07004075 }
sourav parmarbcee7512020-12-28 14:34:49 -08004076 if (pnext_struct->accelerationStructureCount == 0) {
4077 skip |= LogError(device,
4078 "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004079 "%s(): accelerationStructureCount must be greater than 0 .", vkCallingFunction);
sourav parmarbcee7512020-12-28 14:34:49 -08004080 }
4081 const auto *robustness2_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004082 LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
sourav parmarbcee7512020-12-28 14:34:49 -08004083 if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) {
4084 for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) {
4085 if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) {
4086 skip |= LogError(device,
4087 "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749",
4088 "%s(): If the nullDescriptor feature is not enabled, each member of "
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06004089 "pAccelerationStructures must not be VK_NULL_HANDLE.", vkCallingFunction);
sourav parmarcd5fb182020-07-17 12:58:44 -07004090 }
4091 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004092 }
4093 }
4094 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004095 }
4096 }
4097 return skip;
4098}
4099
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07004100bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
4101 const VkWriteDescriptorSet *pDescriptorWrites,
4102 uint32_t descriptorCopyCount,
4103 const VkCopyDescriptorSet *pDescriptorCopies) const {
4104 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
4105}
4106
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004107bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004108 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004109 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004110 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
4111}
4112
sfricke-samsung681ab7b2020-10-29 01:53:35 -07004113bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
4114 const VkAllocationCallbacks *pAllocator,
4115 VkRenderPass *pRenderPass) const {
4116 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4117}
4118
Mike Schuchardt2df08912020-12-15 16:28:09 -08004119bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004120 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004121 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004122 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
4123}
4124
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004125bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
4126 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004127 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004128 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004129
4130 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4131 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
4132 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004133 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
4134 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004135 return skip;
4136}
4137
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004138bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004139 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004140 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02004141
4142 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
4143 const char *cmd_name = "vkBeginCommandBuffer";
Tony-LunarG3c287f62020-12-17 12:39:49 -07004144 bool cb_is_secondary;
4145 {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06004146 auto lock = CBReadLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07004147 cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end());
4148 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004149
Tony-LunarG3c287f62020-12-17 12:39:49 -07004150 if (cb_is_secondary) {
4151 // Implicit VUs
4152 // validate only sType here; pointer has to be validated in core_validation
4153 const bool k_not_required = false;
4154 const char *k_no_vuid = nullptr;
4155 const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo;
4156 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004157 info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid,
4158 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004159
Tony-LunarG3c287f62020-12-17 12:39:49 -07004160 if (info) {
4161 const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = {
David Zhao Akeley44139b12021-04-26 16:16:13 -07004162 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT,
amhagana448ea52021-11-02 14:09:14 -04004163 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR,
4164 VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD,
David Zhao Akeley44139b12021-04-26 16:16:13 -07004165 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV};
Tony-LunarG3c287f62020-12-17 12:39:49 -07004166 skip |= validate_struct_pnext(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004167 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT",
4168 info->pNext, ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info),
4169 allowed_structs_vk_command_buffer_inheritance_info, GeneratedVulkanHeaderVersion,
4170 "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004171
Tony-LunarG3c287f62020-12-17 12:39:49 -07004172 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004173
Tony-LunarG3c287f62020-12-17 12:39:49 -07004174 // Explicit VUs
4175 if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004176 skip |= LogError(
Tony-LunarG3c287f62020-12-17 12:39:49 -07004177 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
4178 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
4179 cmd_name);
4180 }
4181
4182 if (physical_device_features.inheritedQueries) {
4183 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004184 AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags,
4185 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
4186 } else { // !inheritedQueries
Tony-LunarG3c287f62020-12-17 12:39:49 -07004187 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004188 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004189 }
4190
4191 if (physical_device_features.pipelineStatisticsQuery) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004192 skip |=
4193 validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
4194 AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags,
4195 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
4196 } else { // !pipelineStatisticsQuery
4197 skip |=
4198 validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics,
4199 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Tony-LunarG3c287f62020-12-17 12:39:49 -07004200 }
4201
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004202 const auto *conditional_rendering = LvlFindInChain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004203 if (conditional_rendering) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004204 const auto *cr_features = LvlFindInChain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Tony-LunarG3c287f62020-12-17 12:39:49 -07004205 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
4206 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
4207 skip |= LogError(
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004208 commandBuffer,
4209 "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Tony-LunarG3c287f62020-12-17 12:39:49 -07004210 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
4211 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
4212 }
Petr Kraus139757b2019-08-15 17:19:33 +02004213 }
ziga-lunarg9d019132021-07-19 01:05:31 +02004214
4215 auto p_inherited_viewport_scissor_info = LvlFindInChain<VkCommandBufferInheritanceViewportScissorInfoNV>(info->pNext);
4216 if (p_inherited_viewport_scissor_info != nullptr && !physical_device_features.multiViewport &&
4217 p_inherited_viewport_scissor_info->viewportScissor2D == VK_TRUE &&
4218 p_inherited_viewport_scissor_info->viewportDepthCount != 1) {
4219 skip |= LogError(commandBuffer, "VUID-VkCommandBufferInheritanceViewportScissorInfoNV-viewportScissor2D-04783",
4220 "vkBeginCommandBuffer: multiViewport feature is disabled, but "
4221 "VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D in "
4222 "pBeginInfo->pInheritanceInfo->pNext is VK_TRUE and viewportDepthCount is not 1.");
4223 }
Petr Kraus139757b2019-08-15 17:19:33 +02004224 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004225 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004226 return skip;
4227}
4228
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004229bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004230 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004231 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004232
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004233 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01004234 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004235 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
4236 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
4237 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01004238 }
4239 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004240 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
4241 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
4242 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01004243 }
4244 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01004245 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004246 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004247 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
4248 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4249 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4250 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004251 }
4252 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01004253
4254 if (pViewports) {
4255 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
4256 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06004257 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004258 skip |= manual_PreCallValidateViewport(
4259 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01004260 }
4261 }
4262
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004263 return skip;
4264}
4265
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004266bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004267 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004268 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004269
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004270 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004271 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004272 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
4273 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
4274 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004275 }
4276 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004277 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
4278 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
4279 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004280 }
4281 } else { // multiViewport enabled
4282 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004283 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004284 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
4285 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4286 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4287 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004288 }
4289 }
4290
Petr Kraus6260f0a2018-02-27 21:15:55 +01004291 if (pScissors) {
4292 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
4293 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004294
Petr Kraus6260f0a2018-02-27 21:15:55 +01004295 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004296 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4297 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
4298 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004299 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004300
Petr Kraus6260f0a2018-02-27 21:15:55 +01004301 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004302 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
4303 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
4304 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004305 }
4306
4307 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4308 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004309 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
4310 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4311 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4312 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004313 }
4314
4315 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4316 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004317 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
4318 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4319 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4320 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01004321 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004322 }
4323 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01004324
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004325 return skip;
4326}
4327
Jeff Bolz5c801d12019-10-09 10:38:45 -05004328bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01004329 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01004330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004331 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004332 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
4333 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01004334 }
4335
4336 return skip;
4337}
4338
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004339bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004340 uint32_t drawCount, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004341 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004342
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004343 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06004344 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004345 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4346 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004347 }
4348 if (drawCount > device_limits.maxDrawIndirectCount) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004349 skip |=
4350 LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719",
4351 "CmdDrawIndirect(): drawCount (%" PRIu32 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
4352 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004353 }
4354 return skip;
4355}
4356
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004357bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004358 VkDeviceSize offset, uint32_t drawCount,
4359 uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004360 bool skip = false;
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004361 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004362 skip |=
4363 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
4364 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
4365 drawCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07004366 }
4367 if (drawCount > device_limits.maxDrawIndirectCount) {
4368 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004369 "CmdDrawIndexedIndirect(): drawCount (%" PRIu32
4370 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004371 drawCount, device_limits.maxDrawIndirectCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004372 }
4373 return skip;
4374}
4375
sfricke-samsungf692b972020-05-02 08:00:45 -07004376bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4377 VkDeviceSize countBufferOffset, bool khr) const {
4378 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004379 const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004380 if (offset & 3) {
4381 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004382 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004383 }
4384
4385 if (countBufferOffset & 3) {
4386 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004387 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004388 countBufferOffset);
4389 }
4390 return skip;
4391}
4392
4393bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4394 VkDeviceSize offset, VkBuffer countBuffer,
4395 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4396 uint32_t stride) const {
4397 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
4398}
4399
4400bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4401 VkDeviceSize offset, VkBuffer countBuffer,
4402 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4403 uint32_t stride) const {
4404 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
4405}
4406
4407bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
4408 VkDeviceSize countBufferOffset, bool khr) const {
4409 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004410 const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
sfricke-samsungf692b972020-05-02 08:00:45 -07004411 if (offset & 3) {
4412 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004413 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset);
sfricke-samsungf692b972020-05-02 08:00:45 -07004414 }
4415
4416 if (countBufferOffset & 3) {
4417 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004418 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name,
sfricke-samsungf692b972020-05-02 08:00:45 -07004419 countBufferOffset);
4420 }
4421 return skip;
4422}
4423
4424bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
4425 VkDeviceSize offset, VkBuffer countBuffer,
4426 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
4427 uint32_t stride) const {
4428 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
4429}
4430
4431bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
4432 VkDeviceSize offset, VkBuffer countBuffer,
4433 VkDeviceSize countBufferOffset,
4434 uint32_t maxDrawCount, uint32_t stride) const {
4435 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
4436}
4437
Tony-LunarG4490de42021-06-21 15:49:19 -06004438bool StatelessValidation::manual_PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4439 const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount,
4440 uint32_t firstInstance, uint32_t stride) const {
4441 bool skip = false;
4442 if (stride & 3) {
4443 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-stride-04936",
4444 "CmdDrawMultiEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4445 }
4446 if (drawCount && nullptr == pVertexInfo) {
4447 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiEXT-drawCount-04935",
4448 "CmdDrawMultiEXT: parameter, VkMultiDrawInfoEXT *pVertexInfo must be a valid pointer to memory containing "
4449 "one or more valid instances of VkMultiDrawInfoEXT structures");
4450 }
4451 return skip;
4452}
4453
4454bool StatelessValidation::manual_PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount,
4455 const VkMultiDrawIndexedInfoEXT *pIndexInfo,
4456 uint32_t instanceCount, uint32_t firstInstance,
4457 uint32_t stride, const int32_t *pVertexOffset) const {
4458 bool skip = false;
4459 if (stride & 3) {
4460 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-stride-04941",
4461 "CmdDrawMultiIndexedEXT: parameter, uint32_t stride (%" PRIu32 ") is not a multiple of 4.", stride);
4462 }
4463 if (drawCount && nullptr == pIndexInfo) {
4464 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940",
4465 "CmdDrawMultiIndexedEXT: parameter, VkMultiDrawIndexedInfoEXT *pIndexInfo must be a valid pointer to "
4466 "memory containing one or more valid instances of VkMultiDrawIndexedInfoEXT structures");
4467 }
4468 return skip;
4469}
4470
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004471bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
4472 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004473 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004474 bool skip = false;
4475 for (uint32_t rect = 0; rect < rectCount; rect++) {
4476 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004477 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004478 "CmdClearAttachments(): pRects[%" PRIu32 "].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004479 }
sfricke-samsung10867682020-04-25 02:20:39 -07004480 if (pRects[rect].rect.extent.width == 0) {
4481 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004482 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.width is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004483 }
4484 if (pRects[rect].rect.extent.height == 0) {
4485 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004486 "CmdClearAttachments(): pRects[%" PRIu32 "].rect.extent.height is zero.", rect);
sfricke-samsung10867682020-04-25 02:20:39 -07004487 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06004488 }
4489 return skip;
4490}
4491
Andrew Fobel3abeb992020-01-20 16:33:22 -05004492bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
4493 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4494 VkImageFormatProperties2 *pImageFormatProperties,
4495 const char *apiName) const {
4496 bool skip = false;
4497
4498 if (pImageFormatInfo != nullptr) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004499 const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004500 if (image_stencil_struct != nullptr) {
4501 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
4502 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
4503 // No flags other than the legal attachment bits may be set
4504 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
4505 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004506 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
4507 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
4508 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
4509 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
4510 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05004511 }
4512 }
4513 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004514 const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext);
4515 if (image_drm_format) {
4516 if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4517 skip |= LogError(
4518 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4519 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4520 "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4521 apiName, string_VkImageTiling(pImageFormatInfo->tiling));
4522 }
ziga-lunarg27e256d2021-10-07 23:38:12 +02004523 if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) {
4524 skip |= LogError(
4525 physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315",
4526 "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, "
4527 "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".",
4528 apiName, image_drm_format->queueFamilyIndexCount);
4529 }
ziga-lunargd3da2532021-08-11 11:50:12 +02004530 } else {
4531 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4532 skip |= LogError(
4533 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249",
4534 "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include "
4535 "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.",
4536 apiName);
4537 }
4538 }
4539 if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
4540 (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
4541 const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext);
4542 if (!format_list || format_list->viewFormatCount == 0) {
4543 skip |= LogError(
4544 physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313",
4545 "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT "
4546 "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.",
4547 apiName);
4548 }
4549 }
Andrew Fobel3abeb992020-01-20 16:33:22 -05004550 }
4551
4552 return skip;
4553}
4554
4555bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
4556 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4557 VkImageFormatProperties2 *pImageFormatProperties) const {
4558 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4559 "vkGetPhysicalDeviceImageFormatProperties2");
4560}
4561
4562bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
4563 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
4564 VkImageFormatProperties2 *pImageFormatProperties) const {
4565 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
4566 "vkGetPhysicalDeviceImageFormatProperties2KHR");
4567}
4568
Lionel Landwerlin5fe52752020-07-22 08:18:14 +03004569bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties(
4570 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage,
4571 VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const {
4572 bool skip = false;
4573
4574 if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
4575 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248",
4576 "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.");
4577 }
4578
4579 return skip;
4580}
4581
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004582bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceVideoFormatPropertiesKHR(
4583 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR *pVideoFormatInfo,
4584 uint32_t *pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR *pVideoFormatProperties) const {
4585 bool skip = false;
4586
4587 if ((pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR |
4588 VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR)) == 0) {
4589 skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceVideoFormatPropertiesKHR-imageUsage-04844",
4590 "vkGetPhysicalDeviceVideoFormatPropertiesKHR(): pVideoFormatInfo->imageUsage does not contain any of "
4591 "VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR, "
4592 "VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR, or VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR.");
4593 }
4594
ziga-lunarg42f884b2021-08-25 16:13:20 +02004595 return skip;
ziga-lunarg73b5ef22021-07-29 20:25:06 +02004596}
4597
sfricke-samsung3999ef62020-02-09 17:05:59 -08004598bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
4599 uint32_t regionCount, const VkBufferCopy *pRegions) const {
4600 bool skip = false;
4601
4602 if (pRegions != nullptr) {
4603 for (uint32_t i = 0; i < regionCount; i++) {
4604 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004605 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004606 "vkCmdCopyBuffer() pRegions[%" PRIu32 "].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08004607 }
4608 }
4609 }
4610 return skip;
4611}
4612
Jeff Leger178b1e52020-10-05 12:22:23 -04004613bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
4614 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
4615 bool skip = false;
4616
4617 if (pCopyBufferInfo->pRegions != nullptr) {
4618 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
4619 if (pCopyBufferInfo->pRegions[i].size == 0) {
4620 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004621 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%" PRIu32 "].size must be greater than zero", i);
Jeff Leger178b1e52020-10-05 12:22:23 -04004622 }
4623 }
4624 }
4625 return skip;
4626}
4627
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004628bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004629 VkDeviceSize dstOffset, VkDeviceSize dataSize,
4630 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004631 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004632
4633 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004634 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
4635 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4636 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004637 }
4638
4639 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004640 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
4641 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
4642 "), must be greater than zero and less than or equal to 65536.",
4643 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004644 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004645 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
4646 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4647 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004648 }
4649 return skip;
4650}
4651
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004652bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004653 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004654 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004655
4656 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004657 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
4658 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
4659 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004660 }
4661
4662 if (size != VK_WHOLE_SIZE) {
4663 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004664 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004665 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
4666 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004667 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004668 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
4669 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004670 }
4671 }
4672 return skip;
4673}
4674
sfricke-samsunga1d00272021-03-10 21:37:41 -08004675bool StatelessValidation::ValidateSwapchainCreateInfo(const char *func_name, VkSwapchainCreateInfoKHR const *pCreateInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004676 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004677
4678 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004679 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4680 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
4681 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
4682 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004683 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004684 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
4685 "pCreateInfo->queueFamilyIndexCount must be greater than 1.",
4686 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004687 }
4688
4689 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
4690 // queueFamilyIndexCount uint32_t values
4691 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004692 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004693 "%s: if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004694 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
sfricke-samsunga1d00272021-03-10 21:37:41 -08004695 "pCreateInfo->queueFamilyIndexCount uint32_t values.",
4696 func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004697 }
4698 }
4699
Dave Houlton413a6782018-05-22 13:01:54 -06004700 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004701 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", func_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004702
sfricke-samsunga1d00272021-03-10 21:37:41 -08004703 // Validate VK_KHR_image_format_list VkImageFormatListCreateInfo
4704 const auto format_list_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext);
4705 if (format_list_info) {
4706 const uint32_t viewFormatCount = format_list_info->viewFormatCount;
4707 if (((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) == 0) && (viewFormatCount > 1)) {
4708 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-04100",
4709 "%s: If the VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is not set, then "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004710 "VkImageFormatListCreateInfo::viewFormatCount (%" PRIu32
4711 ") must be 0 or 1 if it is in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004712 func_name, viewFormatCount);
4713 }
4714
4715 // Using the first format, compare the rest of the formats against it that they are compatible
4716 for (uint32_t i = 1; i < viewFormatCount; i++) {
4717 if (FormatCompatibilityClass(format_list_info->pViewFormats[0]) !=
4718 FormatCompatibilityClass(format_list_info->pViewFormats[i])) {
4719 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-pNext-04099",
4720 "%s: VkImageFormatListCreateInfo::pViewFormats[0] (%s) and "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07004721 "VkImageFormatListCreateInfo::pViewFormats[%" PRIu32
4722 "] (%s) are not compatible in the pNext chain.",
sfricke-samsunga1d00272021-03-10 21:37:41 -08004723 func_name, string_VkFormat(format_list_info->pViewFormats[0]), i,
4724 string_VkFormat(format_list_info->pViewFormats[i]));
4725 }
4726 }
4727 }
4728
4729 // Validate VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
4730 if ((pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) != 0) {
4731 if (!IsExtEnabled(device_extensions.vk_khr_swapchain_mutable_format)) {
4732 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
4733 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR which requires the "
4734 "VK_KHR_swapchain_mutable_format extension, which has not been enabled.",
4735 func_name);
4736 } else {
4737 if (format_list_info == nullptr) {
4738 skip |= LogError(
4739 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4740 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the pNext chain of "
4741 "pCreateInfo does not contain an instance of VkImageFormatListCreateInfo.",
4742 func_name);
4743 } else if (format_list_info->viewFormatCount == 0) {
4744 skip |= LogError(
4745 device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4746 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but the viewFormatCount "
4747 "member of VkImageFormatListCreateInfo in the pNext chain is zero.",
4748 func_name);
4749 } else {
4750 bool found_base_format = false;
4751 for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
4752 if (format_list_info->pViewFormats[i] == pCreateInfo->imageFormat) {
4753 found_base_format = true;
4754 break;
4755 }
4756 }
4757 if (!found_base_format) {
4758 skip |=
4759 LogError(device, "VUID-VkSwapchainCreateInfoKHR-flags-03168",
4760 "%s: pCreateInfo->flags contains VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR but none of the "
4761 "elements of the pViewFormats member of VkImageFormatListCreateInfo match "
4762 "pCreateInfo->imageFormat.",
4763 func_name);
4764 }
4765 }
4766 }
4767 }
4768 }
4769 return skip;
4770}
4771
4772bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
4773 const VkAllocationCallbacks *pAllocator,
4774 VkSwapchainKHR *pSwapchain) const {
4775 bool skip = false;
4776 skip |= ValidateSwapchainCreateInfo("vkCreateSwapchainKHR()", pCreateInfo);
4777 return skip;
4778}
4779
4780bool StatelessValidation::manual_PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
4781 const VkSwapchainCreateInfoKHR *pCreateInfos,
4782 const VkAllocationCallbacks *pAllocator,
4783 VkSwapchainKHR *pSwapchains) const {
4784 bool skip = false;
4785 if (pCreateInfos) {
4786 for (uint32_t i = 0; i < swapchainCount; i++) {
4787 std::stringstream func_name;
4788 func_name << "vkCreateSharedSwapchainsKHR[" << swapchainCount << "]()";
4789 skip |= ValidateSwapchainCreateInfo(func_name.str().c_str(), &pCreateInfos[i]);
4790 }
4791 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004792 return skip;
4793}
4794
Jeff Bolz5c801d12019-10-09 10:38:45 -05004795bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004796 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004797
4798 if (pPresentInfo && pPresentInfo->pNext) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07004799 const auto *present_regions = LvlFindInChain<VkPresentRegionsKHR>(pPresentInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -06004800 if (present_regions) {
4801 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07004802 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06004803 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
4804 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07004805 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004806 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
4807 "extension swapchainCount is %i. These values must be equal.",
4808 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06004809 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004810 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08004811 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
4812 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004813 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
4814 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
4815 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06004816 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004817 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004818 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06004819 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004820 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004821 }
4822 }
4823
4824 return skip;
4825}
4826
sfricke-samsung5c1b7392020-12-13 22:17:15 -08004827bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
4828 const VkDisplayModeCreateInfoKHR *pCreateInfo,
4829 const VkAllocationCallbacks *pAllocator,
4830 VkDisplayModeKHR *pMode) const {
4831 bool skip = false;
4832
4833 const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters;
4834 if (display_mode_parameters.visibleRegion.width == 0) {
4835 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990",
4836 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0.");
4837 }
4838 if (display_mode_parameters.visibleRegion.height == 0) {
4839 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991",
4840 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0.");
4841 }
4842 if (display_mode_parameters.refreshRate == 0) {
4843 skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992",
4844 "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0.");
4845 }
4846
4847 return skip;
4848}
4849
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004850#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004851bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
4852 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
4853 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004854 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004855 bool skip = false;
4856
4857 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004858 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
4859 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004860 }
4861
4862 return skip;
4863}
4864#endif // VK_USE_PLATFORM_WIN32_KHR
4865
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004866static bool MutableDescriptorTypePartialOverlap(const VkDescriptorPoolCreateInfo *pCreateInfo, uint32_t i, uint32_t j) {
4867 bool partial_overlap = false;
4868
4869 static const std::vector<VkDescriptorType> all_descriptor_types = {
4870 VK_DESCRIPTOR_TYPE_SAMPLER,
4871 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
4872 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
4873 VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
4874 VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
4875 VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
4876 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
4877 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
4878 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
4879 VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
4880 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
4881 VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT,
4882 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
4883 VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
4884 };
4885
4886 const auto *mutable_descriptor_type = LvlFindInChain<VkMutableDescriptorTypeCreateInfoVALVE>(pCreateInfo->pNext);
4887 if (mutable_descriptor_type) {
4888 std::vector<VkDescriptorType> first_types, second_types;
4889 if (mutable_descriptor_type->mutableDescriptorTypeListCount > i) {
4890 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[i].descriptorTypeCount; ++k) {
4891 first_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[i].pDescriptorTypes[k]);
4892 }
4893 } else {
4894 first_types = all_descriptor_types;
4895 }
4896 if (mutable_descriptor_type->mutableDescriptorTypeListCount > j) {
4897 for (uint32_t k = 0; k < mutable_descriptor_type->pMutableDescriptorTypeLists[j].descriptorTypeCount; ++k) {
4898 second_types.push_back(mutable_descriptor_type->pMutableDescriptorTypeLists[j].pDescriptorTypes[k]);
4899 }
4900 } else {
4901 second_types = all_descriptor_types;
4902 }
4903
4904 bool complete_overlap = first_types.size() == second_types.size();
4905 bool disjoint = true;
4906 for (const auto first_type : first_types) {
4907 bool found = false;
4908 for (const auto second_type : second_types) {
4909 if (first_type == second_type) {
4910 found = true;
4911 break;
4912 }
4913 }
4914 if (found) {
4915 disjoint = false;
4916 } else {
4917 complete_overlap = false;
4918 }
4919 if (!disjoint && !complete_overlap) {
4920 partial_overlap = true;
4921 break;
4922 }
4923 }
4924 }
4925
4926 return partial_overlap;
4927}
4928
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004929bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004930 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004931 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02004932 bool skip = false;
4933
4934 if (pCreateInfo) {
4935 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004936 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
4937 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02004938 }
4939
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004940 const auto *mutable_descriptor_type_features =
4941 LvlFindInChain<VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE>(device_createinfo_pnext);
4942 bool mutable_descriptor_type_enabled =
4943 mutable_descriptor_type_features && mutable_descriptor_type_features->mutableDescriptorType == VK_TRUE;
4944
Petr Krausc8655be2017-09-27 18:56:51 +02004945 if (pCreateInfo->pPoolSizes) {
4946 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
4947 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004948 skip |= LogError(
4949 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06004950 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02004951 }
Jeff Bolze54ae892018-09-08 12:16:29 -05004952 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
4953 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004954 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
4955 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4956 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
4957 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
4958 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05004959 }
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004960 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE && !mutable_descriptor_type_enabled) {
4961 skip |=
4962 LogError(device, "VUID-VkDescriptorPoolCreateInfo-mutableDescriptorType-04608",
4963 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4964 "].type is VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
4965 ", but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.",
4966 i);
4967 }
4968 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4969 for (uint32_t j = i + 1; j < pCreateInfo->poolSizeCount; ++j) {
4970 if (pCreateInfo->pPoolSizes[j].type == VK_DESCRIPTOR_TYPE_MUTABLE_VALVE) {
4971 if (MutableDescriptorTypePartialOverlap(pCreateInfo, i, j)) {
4972 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-pPoolSizes-04787",
4973 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
4974 "].type and pCreateInfo->pPoolSizes[%" PRIu32
4975 "].type are both VK_DESCRIPTOR_TYPE_MUTABLE_VALVE "
4976 " and have sets which partially overlap.",
4977 i, j);
4978 }
4979 }
4980 }
4981 }
Petr Krausc8655be2017-09-27 18:56:51 +02004982 }
4983 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004984
ziga-lunarg0bc679d2021-10-15 15:55:19 +02004985 if (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE && (!mutable_descriptor_type_enabled)) {
4986 skip |=
4987 LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04609",
4988 "vkCreateDescriptorPool(): pCreateInfo->flags contains VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE, "
4989 "but VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE::mutableDescriptorType is not enabled.");
4990 }
ziga-lunarg0cf85212021-07-19 01:26:17 +02004991 if ((pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE) &&
4992 (pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT)) {
4993 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-flags-04607",
4994 "vkCreateDescriptorPool(): pCreateInfo->flags must not contain both "
4995 "VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT");
4996 }
Petr Krausc8655be2017-09-27 18:56:51 +02004997 }
4998
4999 return skip;
5000}
5001
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005002bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005003 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005004 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005005
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005006 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005007 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005008 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
5009 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5010 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005011 }
5012
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005013 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005014 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005015 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
5016 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5017 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005018 }
5019
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005020 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06005021 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005022 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
5023 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5024 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005025 }
5026
5027 return skip;
5028}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005029
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005030bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005031 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07005032 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07005033
5034 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005035 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
5036 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07005037 }
5038 return skip;
5039}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005040
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005041bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
5042 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005043 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005044 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005045
5046 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005047 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005048 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005049 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
5050 "vkCmdDispatch(): baseGroupX (%" PRIu32
5051 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5052 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005053 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005054 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
5055 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
5056 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
5057 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005058 }
5059
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005060 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005061 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005062 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
5063 "vkCmdDispatch(): baseGroupY (%" PRIu32
5064 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5065 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005066 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005067 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
5068 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
5069 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
5070 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005071 }
5072
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005073 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005074 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005075 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
5076 "vkCmdDispatch(): baseGroupZ (%" PRIu32
5077 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5078 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005079 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005080 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
5081 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
5082 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
5083 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07005084 }
5085
5086 return skip;
5087}
5088
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07005089bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
5090 VkPipelineBindPoint pipelineBindPoint,
5091 VkPipelineLayout layout, uint32_t set,
5092 uint32_t descriptorWriteCount,
5093 const VkWriteDescriptorSet *pDescriptorWrites) const {
5094 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
5095}
5096
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005097bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
5098 uint32_t firstExclusiveScissor,
5099 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005100 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005101 bool skip = false;
5102
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005103 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05005104 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005105 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005106 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
5107 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
5108 ") is not 0.",
5109 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005110 }
5111 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005112 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005113 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
5114 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
5115 ") is not 1.",
5116 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005117 }
5118 } else { // multiViewport enabled
5119 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005120 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005121 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
5122 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
5123 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5124 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005125 }
5126 }
5127
Jeff Bolz3e71f782018-08-29 23:15:45 -05005128 if (pExclusiveScissors) {
5129 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
5130 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
5131
5132 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005133 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5134 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
5135 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005136 }
5137
5138 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005139 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
5140 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
5141 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005142 }
5143
5144 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5145 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005146 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
5147 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5148 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5149 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005150 }
5151
5152 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5153 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005154 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
5155 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5156 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5157 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05005158 }
5159 }
5160 }
5161
5162 return skip;
5163}
5164
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005165bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
5166 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005167 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005168 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07005169 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
5170 if ((sum < 1) || (sum > device_limits.maxViewports)) {
5171 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
5172 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
5173 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
5174 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02005175 }
5176
5177 return skip;
5178}
5179
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005180bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
5181 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005182 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005183 bool skip = false;
5184
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005185 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005186 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005187 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005188 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
5189 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
5190 ") is not 0.",
5191 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005192 }
5193 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06005194 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005195 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
5196 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5197 ") is not 1.",
5198 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005199 }
5200 }
5201
Jeff Bolz9af91c52018-09-01 21:53:57 -05005202 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005203 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005204 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
5205 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
5206 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5207 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005208 }
5209
5210 return skip;
5211}
5212
Jeff Bolz5c801d12019-10-09 10:38:45 -05005213bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
5214 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
5215 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05005216 bool skip = false;
5217
Dave Houlton142c4cb2018-10-17 15:04:41 -06005218 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005219 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
5220 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
5221 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05005222 }
5223
5224 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005225 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05005226 }
5227
5228 return skip;
5229}
5230
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005231bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005232 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005233 bool skip = false;
5234
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005235 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005236 skip |= LogError(
5237 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005238 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
5239 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005240 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005241 }
5242
5243 return skip;
5244}
5245
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005246bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5247 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005248 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005249 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06005250 static const int condition_multiples = 0b0011;
5251 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005252 skip |= LogError(
5253 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06005254 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005255 }
Lockee1c22882019-06-10 16:02:54 -06005256 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005257 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
5258 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
5259 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
5260 stride);
Lockee1c22882019-06-10 16:02:54 -06005261 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005262 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005263 skip |= LogError(
5264 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005265 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %" PRIu32 "",
5266 drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06005267 }
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005268 if (drawCount > device_limits.maxDrawIndirectCount) {
5269 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005270 "vkCmdDrawMeshTasksIndirectNV: drawCount (%" PRIu32
5271 ") is not less than or equal to the maximum allowed (%" PRIu32 ").",
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005272 drawCount, device_limits.maxDrawIndirectCount);
Tony-LunarGc0c3df52020-11-20 13:47:10 -07005273 }
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005274 return skip;
5275}
5276
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005277bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
5278 VkDeviceSize offset, VkBuffer countBuffer,
5279 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005280 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005281 bool skip = false;
5282
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005283 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005284 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
5285 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
5286 "), is not a multiple of 4.",
5287 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005288 }
5289
5290 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005291 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
5292 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
5293 "), is not a multiple of 4.",
5294 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005295 }
5296
Jeff Bolz45bf7d62018-09-18 15:39:58 -05005297 return skip;
5298}
5299
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005300bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005301 const VkAllocationCallbacks *pAllocator,
5302 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005303 bool skip = false;
5304
5305 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
5306 if (pCreateInfo != nullptr) {
5307 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
5308 // VkQueryPipelineStatisticFlagBits values
5309 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
5310 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005311 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
5312 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
5313 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
5314 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005315 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07005316 if (pCreateInfo->queryCount == 0) {
5317 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
5318 "vkCreateQueryPool(): queryCount must be greater than zero.");
5319 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06005320 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005321 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005322}
5323
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005324bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
5325 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005326 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005327 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
5328 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005329}
5330
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005331void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005332 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5333 VkResult result) {
5334 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005335 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005336}
5337
Mike Schuchardt2df08912020-12-15 16:28:09 -08005338void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005339 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
5340 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005341 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07005342 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005343 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005344}
5345
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07005346void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
5347 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005348 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07005349 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07005350 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005351}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005352
Tony-LunarG3c287f62020-12-17 12:39:49 -07005353void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005354 VkCommandBuffer *pCommandBuffers, VkResult result) {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005355 if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005356 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005357 for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) {
Jeremy Gebbenfc6f8152021-03-18 16:58:55 -06005358 secondary_cb_map.emplace(pCommandBuffers[cb_index], pAllocateInfo->commandPool);
Tony-LunarG3c287f62020-12-17 12:39:49 -07005359 }
5360 }
5361}
5362
5363void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005364 const VkCommandBuffer *pCommandBuffers) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005365 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005366 for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) {
5367 secondary_cb_map.erase(pCommandBuffers[cb_index]);
5368 }
5369}
5370
5371void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool,
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005372 const VkAllocationCallbacks *pAllocator) {
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06005373 auto lock = CBWriteLock();
Tony-LunarG3c287f62020-12-17 12:39:49 -07005374 for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) {
5375 if (item->second == commandPool) {
5376 item = secondary_cb_map.erase(item);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005377 } else {
Tony-LunarG3c287f62020-12-17 12:39:49 -07005378 ++item;
5379 }
5380 }
5381}
5382
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005383bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005384 const VkAllocationCallbacks *pAllocator,
5385 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005386 bool skip = false;
5387
5388 if (pAllocateInfo) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005389 auto chained_prio_struct = LvlFindInChain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005390 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005391 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
5392 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005393 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005394
5395 VkMemoryAllocateFlags flags = 0;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005396 auto flags_info = LvlFindInChain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005397 if (flags_info) {
5398 flags = flags_info->flags;
5399 }
5400
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005401 auto opaque_alloc_info = LvlFindInChain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005402 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08005403 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005404 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
5405 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
Mike Schuchardt2df08912020-12-15 16:28:09 -08005406 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005407 }
5408
5409#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005410 auto import_memory_win32_handle = LvlFindInChain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005411#endif
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005412 auto import_memory_fd = LvlFindInChain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
5413 auto import_memory_host_pointer = LvlFindInChain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005414#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005415 auto import_memory_ahb = LvlFindInChain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005416#endif
5417
5418 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005419 skip |= LogError(
5420 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005421 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
5422 }
5423 if (
5424#ifdef VK_USE_PLATFORM_WIN32_KHR
5425 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
5426#endif
5427 (import_memory_fd && import_memory_fd->handleType) ||
5428#ifdef VK_USE_PLATFORM_ANDROID_KHR
5429 (import_memory_ahb && import_memory_ahb->buffer) ||
5430#endif
5431 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005432 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
5433 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005434 }
5435 }
5436
ziga-lunarg1d5e11d2021-07-18 13:13:40 +02005437 auto export_memory = LvlFindInChain<VkExportMemoryAllocateInfo>(pAllocateInfo->pNext);
5438 if (export_memory) {
5439 auto export_memory_nv = LvlFindInChain<VkExportMemoryAllocateInfoNV>(pAllocateInfo->pNext);
5440 if (export_memory_nv) {
5441 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5442 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5443 "VkExportMemoryAllocateInfoNV");
5444 }
5445#ifdef VK_USE_PLATFORM_WIN32_KHR
5446 auto export_memory_win32_nv = LvlFindInChain<VkExportMemoryWin32HandleInfoNV>(pAllocateInfo->pNext);
5447 if (export_memory_win32_nv) {
5448 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-pNext-00640",
5449 "pNext chain of VkMemoryAllocateInfo includes both VkExportMemoryAllocateInfo and "
5450 "VkExportMemoryWin32HandleInfoNV");
5451 }
5452#endif
5453 }
5454
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005455 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005456 VkBool32 capture_replay = false;
5457 VkBool32 buffer_device_address = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005458 const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005459 if (vulkan_12_features) {
5460 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
5461 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
5462 } else {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005463 const auto *bda_features = LvlFindInChain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07005464 if (bda_features) {
5465 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
5466 buffer_device_address = bda_features->bufferDeviceAddress;
5467 }
5468 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005469 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005470 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005471 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005472 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005473 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08005474 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005475 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08005476 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06005477 }
5478 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06005479 }
5480 return skip;
5481}
Ricardo Garciaa4935972019-02-21 17:43:18 +01005482
Jason Macnak192fa0e2019-07-26 15:07:16 -07005483bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005484 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005485 bool skip = false;
5486
5487 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
5488 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
5489 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005490 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005491 } else {
5492 uint32_t vertex_component_size = 0;
5493 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
5494 vertex_component_size = 4;
5495 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
5496 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
5497 vertex_component_size = 2;
5498 }
5499 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005500 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005501 }
5502 }
5503
5504 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
5505 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005506 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005507 } else {
5508 uint32_t index_element_size = 0;
5509 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
5510 index_element_size = 4;
5511 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
5512 index_element_size = 2;
5513 }
5514 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005515 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005516 }
5517 }
5518 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
5519 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005520 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005521 }
5522 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005523 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005524 }
5525 }
5526
5527 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005528 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005529 }
5530
5531 return skip;
5532}
5533
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005534bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
5535 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005536 bool skip = false;
5537
5538 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005539 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005540 }
5541 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005542 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005543 }
5544
5545 return skip;
5546}
5547
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005548bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
5549 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07005550 bool skip = false;
5551 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005552 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005553 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005554 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005555 }
5556 return skip;
5557}
5558
5559bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07005560 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005561 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005562 bool skip = false;
5563 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005564 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
5565 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
5566 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005567 }
5568 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005569 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
5570 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
5571 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07005572 }
ziga-lunarg10309ee2021-08-02 13:11:21 +02005573 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5574 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-04623",
5575 "VkAccelerationStructureInfoNV: type is invalid VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.");
5576 }
Jason Macnak5c954952019-07-09 15:46:12 -07005577 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
5578 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005579 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
5580 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
5581 "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 -07005582 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005583 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005584 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005585 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
5586 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005587 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
5588 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005589 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005590 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005591 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
5592 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
5593 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005594 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005595 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07005596 uint64_t total_triangle_count = 0;
5597 for (uint32_t i = 0; i < info.geometryCount; i++) {
5598 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07005599
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005600 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07005601
Jason Macnak5c954952019-07-09 15:46:12 -07005602 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
5603 continue;
5604 }
5605 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
5606 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005607 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005608 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
5609 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
5610 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07005611 }
5612 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07005613 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
5614 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
5615 for (uint32_t i = 1; i < info.geometryCount; i++) {
5616 const VkGeometryNV &geometry = info.pGeometries[i];
5617 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005618 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005619 "VkAccelerationStructureInfoNV: info.pGeometries[%" PRIu32
5620 "].geometryType does not match "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005621 "info.pGeometries[0].geometryType.",
5622 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07005623 }
5624 }
5625 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005626 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
5627 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
5628 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
5629 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
5630 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
5631 "or VK_GEOMETRY_TYPE_AABBS_NV.");
5632 }
5633 }
5634 skip |=
5635 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06005636 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07005637 return skip;
5638}
5639
Ricardo Garciaa4935972019-02-21 17:43:18 +01005640bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
5641 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005642 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01005643 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01005644 if (pCreateInfo) {
5645 if ((pCreateInfo->compactedSize != 0) &&
5646 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005647 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
5648 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
5649 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
5650 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005651 }
Jason Macnak5c954952019-07-09 15:46:12 -07005652
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005653 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07005654 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01005655 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01005656 return skip;
5657}
Mike Schuchardt21638df2019-03-16 10:52:02 -07005658
Jeff Bolz5c801d12019-10-09 10:38:45 -05005659bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
5660 const VkAccelerationStructureInfoNV *pInfo,
5661 VkBuffer instanceData, VkDeviceSize instanceOffset,
5662 VkBool32 update, VkAccelerationStructureNV dst,
5663 VkAccelerationStructureNV src, VkBuffer scratch,
5664 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005665 bool skip = false;
5666
5667 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005668 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07005669 }
5670
5671 return skip;
5672}
5673
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005674bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
5675 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5676 VkAccelerationStructureKHR *pAccelerationStructure) const {
5677 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005678 const auto *acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005679 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005680 if (!acceleration_structure_features ||
5681 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
5682 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
5683 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
5684 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005685 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005686 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
5687 (!acceleration_structure_features ||
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005688 (acceleration_structure_features &&
5689 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07005690 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07005691 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
5692 "vkCreateAccelerationStructureKHR(): If createFlags includes "
5693 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
5694 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07005695 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005696 if (pCreateInfo->deviceAddress &&
5697 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
5698 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
5699 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
5700 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
5701 }
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005702 if (pCreateInfo->deviceAddress && (!acceleration_structure_features ||
5703 (acceleration_structure_features &&
5704 acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
5705 skip |= LogError(
5706 device, "VUID-vkCreateAccelerationStructureKHR-deviceAddress-03488",
5707 "VkAccelerationStructureCreateInfoKHR(): VkAccelerationStructureCreateInfoKHR::deviceAddress is not zero, but "
5708 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay is not enabled.");
5709 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005710 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
5711 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
ziga-lunarg8ddbe462021-09-06 16:14:17 +02005712 "vkCreateAccelerationStructureKHR(): offset %" PRIu64 " must be a multiple of 256 bytes",
5713 pCreateInfo->offset);
sourav parmarcd5fb182020-07-17 12:58:44 -07005714 }
sourav parmar83c31b12020-05-06 12:30:54 -07005715 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005716 return skip;
5717}
5718
Jason Macnak5c954952019-07-09 15:46:12 -07005719bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
5720 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005721 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07005722 bool skip = false;
5723 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005724 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
5725 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07005726 }
5727 return skip;
5728}
5729
sourav parmarcd5fb182020-07-17 12:58:44 -07005730bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
5731 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
5732 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5733 bool skip = false;
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005734 if (queryType != VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07005735 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216",
sourav parmarcd5fb182020-07-17 12:58:44 -07005736 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
Mark Lobodzinskic0df6b62021-01-08 12:34:11 -07005737 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV.");
sourav parmarcd5fb182020-07-17 12:58:44 -07005738 }
5739 return skip;
5740}
5741
Peter Chen85366392019-05-14 15:20:11 -04005742bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
5743 uint32_t createInfoCount,
5744 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
5745 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005746 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04005747 bool skip = false;
5748
5749 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005750 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5751 std::stringstream msg;
5752 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5753 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesNV", msg.str().c_str(), &pCreateInfos[i].pStages[i]);
5754 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005755 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Peter Chen85366392019-05-14 15:20:11 -04005756 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07005757 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005758 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
5759 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
5760 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
5761 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04005762 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005763
5764 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005765 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005766 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5767 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5768 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5769 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
5770 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
5771 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5772 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5773 }
5774 }
5775
sourav parmarf4a78252020-04-10 13:04:21 -07005776 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
5777 skip |=
5778 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
5779 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
5780 }
5781 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
5782 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
5783 skip |=
5784 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
5785 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
5786 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
5787 }
5788 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5789 if (pCreateInfos[i].basePipelineIndex != -1) {
5790 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5791 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
5792 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
5793 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5794 "and pCreateInfos->basePipelineIndex is not -1.");
5795 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005796 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005797 skip |=
5798 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
5799 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
5800 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
5801 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
5802 "that element.");
5803 }
sourav parmarf4a78252020-04-10 13:04:21 -07005804 }
5805 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005806 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005807 skip |=
5808 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
5809 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5810 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
5811 "commands pCreateInfos parameter.");
5812 }
5813 } else {
5814 if (pCreateInfos[i].basePipelineIndex != -1) {
5815 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
5816 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
5817 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
5818 }
5819 }
5820 }
5821 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
5822 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
5823 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
5824 }
5825 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
5826 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
5827 "vkCreateRayTracingPipelinesNV: flags must not include "
5828 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
5829 }
5830 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
5831 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
5832 "vkCreateRayTracingPipelinesNV: flags must not include "
5833 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
5834 }
5835 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
5836 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
5837 "vkCreateRayTracingPipelinesNV: flags must not include "
5838 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
5839 }
5840 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
5841 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
5842 "vkCreateRayTracingPipelinesNV: flags must not include "
5843 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
5844 }
5845 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5846 skip |= LogError(
5847 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
5848 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5849 }
5850 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5851 skip |= LogError(
5852 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
5853 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
5854 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005855 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
5856 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
5857 "vkCreateRayTracingPipelinesNV: flags must not include "
5858 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5859 }
5860 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5861 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
5862 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
5863 }
ziga-lunargdfffee42021-10-10 11:49:59 +02005864 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV) {
5865 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-04948",
5866 "vkCreateRayTracingPipelinesNV: flags must not contain the "
5867 "VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV flag.");
5868 }
Peter Chen85366392019-05-14 15:20:11 -04005869 }
5870
5871 return skip;
5872}
5873
sourav parmarcd5fb182020-07-17 12:58:44 -07005874bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
5875 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
5876 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005877 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005878 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005879 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
5880 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
5881 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005882 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005883 for (uint32_t i = 0; i < createInfoCount; i++) {
ziga-lunargc6341372021-07-28 12:57:42 +02005884 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
5885 std::stringstream msg;
5886 msg << "pCreateInfos[%" << i << "].pStages[%" << stage_index << "]";
5887 ValidatePipelineShaderStageCreateInfo("vkCreateRayTracingPipelinesKHR", msg.str().c_str(),
5888 &pCreateInfos[i].pStages[i]);
5889 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005890 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
5891 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
5892 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
5893 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5894 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
5895 }
5896 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
5897 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
5898 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
5899 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
5900 }
5901 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005902 auto feedback_struct = LvlFindInChain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005903 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
5904 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07005905 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
5906 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
5907 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05005908 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
5909 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
5910 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005911 const auto *pipeline_cache_contol_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07005912 LvlFindInChain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
sourav parmara96ab1a2020-04-25 16:28:23 -07005913 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
5914 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
5915 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
5916 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07005917 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07005918 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
5919 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
5920 }
5921 }
sourav parmarf4a78252020-04-10 13:04:21 -07005922 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005923 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
5924 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07005925 }
5926 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005927 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07005928 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07005929 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
5930 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005931 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005932 }
5933 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
5934 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
5935 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07005936 }
5937 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
5938 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
5939 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
5940 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
5941 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
5942 skip |= LogError(
5943 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07005944 "vkCreateRayTracingPipelinesKHR: If flags includes "
5945 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005946 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5947 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
5948 "must not be VK_SHADER_UNUSED_KHR");
5949 }
5950 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
5951 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
5952 skip |= LogError(
5953 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07005954 "vkCreateRayTracingPipelinesKHR: If flags includes "
5955 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07005956 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
5957 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
5958 "element must not be VK_SHADER_UNUSED_KHR");
5959 }
5960 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005961 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
5962 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
5963 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
5964 skip |= LogError(
5965 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
5966 "vkCreateRayTracingPipelinesKHR: If "
5967 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
5968 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
5969 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
5970 }
5971 }
sourav parmarf4a78252020-04-10 13:04:21 -07005972 }
5973 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
5974 if (pCreateInfos[i].basePipelineIndex != -1) {
5975 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
5976 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07005977 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07005978 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
5979 "and pCreateInfos->basePipelineIndex is not -1.");
5980 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005981 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005982 skip |=
5983 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
5984 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
5985 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
5986 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
5987 "element.");
5988 }
sourav parmarf4a78252020-04-10 13:04:21 -07005989 }
5990 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04005991 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07005992 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07005993 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07005994 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%" PRId32
5995 ") must be a valid into the calling"
5996 "commands pCreateInfos parameter %" PRIu32 ".",
sourav parmarf4a78252020-04-10 13:04:21 -07005997 pCreateInfos[i].basePipelineIndex, createInfoCount);
5998 }
5999 } else {
6000 if (pCreateInfos[i].basePipelineIndex != -1) {
6001 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07006002 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07006003 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
6004 }
6005 }
6006 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006007 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
6008 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
6009 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
6010 "vkCreateRayTracingPipelinesKHR: If flags includes "
6011 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
6012 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006013 }
6014 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
6015 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
6016 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
6017 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
6018 "pLibraryInfo and pLibraryInterface must be NULL.");
6019 }
6020 if (pCreateInfos[i].pLibraryInfo) {
6021 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
6022 if (pCreateInfos[i].stageCount == 0) {
6023 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
6024 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6025 "stageCount must not be 0.");
6026 }
6027 if (pCreateInfos[i].groupCount == 0) {
6028 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
6029 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
6030 "groupCount must not be 0.");
6031 }
6032 } else {
6033 if (pCreateInfos[i].pLibraryInterface == NULL) {
6034 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
6035 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
6036 "is greater than 0, its "
6037 "pLibraryInterface member must not be NULL.");
sourav parmarcd5fb182020-07-17 12:58:44 -07006038 }
6039 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006040 }
6041 if (pCreateInfos[i].pLibraryInterface) {
6042 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
6043 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
6044 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
6045 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
6046 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
6047 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006048 }
6049 if (deferredOperation != VK_NULL_HANDLE) {
6050 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
6051 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
6052 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
6053 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07006054 }
6055 }
ziga-lunargdea76582021-09-17 14:38:08 +02006056 if (pCreateInfos[i].pDynamicState) {
6057 for (uint32_t j = 0; j < pCreateInfos[i].pDynamicState->dynamicStateCount; ++j) {
6058 if (pCreateInfos[i].pDynamicState->pDynamicStates[j] != VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR) {
6059 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pDynamicStates-03602",
6060 "vkCreateRayTracingPipelinesKHR(): pCreateInfos[%" PRIu32
6061 "].pDynamicState->pDynamicStates[%" PRIu32 "] is %s.",
6062 i, j, string_VkDynamicState(pCreateInfos[i].pDynamicState->pDynamicStates[j]));
6063 }
6064 }
6065 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05006066 }
6067
6068 return skip;
6069}
6070
Mike Schuchardt21638df2019-03-16 10:52:02 -07006071#ifdef VK_USE_PLATFORM_WIN32_KHR
6072bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
6073 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006074 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07006075 bool skip = false;
sfricke-samsung45996a42021-09-16 13:45:27 -07006076 if (!IsExtEnabled(device_extensions.vk_khr_swapchain))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006077 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006078 if (!IsExtEnabled(device_extensions.vk_khr_get_surface_capabilities2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006079 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006080 if (!IsExtEnabled(device_extensions.vk_khr_surface))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006081 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006082 if (!IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006083 skip |=
6084 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
sfricke-samsung45996a42021-09-16 13:45:27 -07006085 if (!IsExtEnabled(device_extensions.vk_ext_full_screen_exclusive))
Mike Schuchardt21638df2019-03-16 10:52:02 -07006086 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
6087 skip |= validate_struct_type(
6088 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
6089 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
6090 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
6091 if (pSurfaceInfo != NULL) {
6092 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
6093 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
6094 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
6095
6096 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
6097 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
6098 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
6099 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08006100 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
6101 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07006102
6103 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
6104 }
6105 return skip;
6106}
6107#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01006108
6109bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
6110 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006111 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006112 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
6113 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08006114 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01006115 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
6116 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
6117 }
6118 return skip;
6119}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006120
6121bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006122 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006123 bool skip = false;
6124
6125 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006126 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006127 "vkCmdSetLineStippleEXT::lineStippleFactor=%" PRIu32 " is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05006128 }
6129
6130 return skip;
6131}
Piers Daniell8fd03f52019-08-21 12:07:53 -06006132
6133bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006134 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06006135 bool skip = false;
6136
6137 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006138 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
6139 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006140 }
6141
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006142 const auto *index_type_uint8_features = LvlFindInChain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06006143 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006144 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
6145 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06006146 }
6147
6148 return skip;
6149}
Mark Lobodzinski84988402019-09-11 15:27:30 -06006150
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006151bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
6152 uint32_t bindingCount, const VkBuffer *pBuffers,
6153 const VkDeviceSize *pOffsets) const {
6154 bool skip = false;
6155 if (firstBinding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006156 skip |=
6157 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
6158 "vkCmdBindVertexBuffers() firstBinding (%" PRIu32 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
6159 firstBinding, device_limits.maxVertexInputBindings);
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006160 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
6161 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006162 "vkCmdBindVertexBuffers() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
6163 ") must be less than "
6164 "maxVertexInputBindings (%" PRIu32 ")",
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006165 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
6166 }
6167
Jeff Bolz165818a2020-05-08 11:19:03 -05006168 for (uint32_t i = 0; i < bindingCount; ++i) {
6169 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006170 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Jeff Bolz165818a2020-05-08 11:19:03 -05006171 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006172 skip |=
6173 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
6174 "vkCmdBindVertexBuffers() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006175 } else {
6176 if (pOffsets[i] != 0) {
6177 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006178 "vkCmdBindVertexBuffers() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
6179 "] is not 0",
6180 i, i);
Jeff Bolz165818a2020-05-08 11:19:03 -05006181 }
6182 }
6183 }
6184 }
6185
sfricke-samsung4ada8d42020-02-09 17:43:11 -08006186 return skip;
6187}
6188
Mark Lobodzinski84988402019-09-11 15:27:30 -06006189bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006190 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006191 bool skip = false;
6192 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006193 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
6194 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006195 }
6196 return skip;
6197}
6198
6199bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05006200 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06006201 bool skip = false;
6202 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006203 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
6204 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06006205 }
6206 return skip;
6207}
Petr Kraus3d720392019-11-13 02:52:39 +01006208
6209bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
6210 VkSemaphore semaphore, VkFence fence,
6211 uint32_t *pImageIndex) const {
6212 bool skip = false;
6213
6214 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006215 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
6216 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006217 }
6218
6219 return skip;
6220}
6221
6222bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
6223 uint32_t *pImageIndex) const {
6224 bool skip = false;
6225
6226 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006227 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
6228 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01006229 }
6230
6231 return skip;
6232}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006233
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006234bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
6235 uint32_t firstBinding, uint32_t bindingCount,
6236 const VkBuffer *pBuffers,
6237 const VkDeviceSize *pOffsets,
6238 const VkDeviceSize *pSizes) const {
6239 bool skip = false;
6240
6241 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
6242 for (uint32_t i = 0; i < bindingCount; ++i) {
6243 if (pOffsets[i] & 3) {
6244 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
6245 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
6246 }
6247 }
6248
6249 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6250 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
6251 "%s: The firstBinding(%" PRIu32
6252 ") index is greater than or equal to "
6253 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6254 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6255 }
6256
6257 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6258 skip |=
6259 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
6260 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
6261 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6262 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6263 }
6264
6265 for (uint32_t i = 0; i < bindingCount; ++i) {
6266 // pSizes is optional and may be nullptr.
6267 if (pSizes != nullptr) {
6268 if (pSizes[i] != VK_WHOLE_SIZE &&
6269 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
6270 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
6271 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
6272 ") is not VK_WHOLE_SIZE and is greater than "
6273 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
6274 cmd_name, i, pSizes[i]);
6275 }
6276 }
6277 }
6278
6279 return skip;
6280}
6281
6282bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6283 uint32_t firstCounterBuffer,
6284 uint32_t counterBufferCount,
6285 const VkBuffer *pCounterBuffers,
6286 const VkDeviceSize *pCounterBufferOffsets) const {
6287 bool skip = false;
6288
6289 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
6290 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6291 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
6292 "%s: The firstCounterBuffer(%" PRIu32
6293 ") index is greater than or equal to "
6294 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6295 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6296 }
6297
6298 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6299 skip |=
6300 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
6301 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6302 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6303 cmd_name, firstCounterBuffer, counterBufferCount,
6304 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6305 }
6306
6307 return skip;
6308}
6309
6310bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
6311 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
6312 const VkBuffer *pCounterBuffers,
6313 const VkDeviceSize *pCounterBufferOffsets) const {
6314 bool skip = false;
6315
6316 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
6317 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6318 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
6319 "%s: The firstCounterBuffer(%" PRIu32
6320 ") index is greater than or equal to "
6321 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6322 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6323 }
6324
6325 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
6326 skip |=
6327 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
6328 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
6329 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
6330 cmd_name, firstCounterBuffer, counterBufferCount,
6331 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
6332 }
6333
6334 return skip;
6335}
6336
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006337bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
6338 uint32_t firstInstance, VkBuffer counterBuffer,
6339 VkDeviceSize counterBufferOffset,
6340 uint32_t counterOffset, uint32_t vertexStride) const {
6341 bool skip = false;
6342
6343 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006344 skip |= LogError(counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
6345 "vkCmdDrawIndirectByteCountEXT: vertexStride (%" PRIu32
6346 ") must be between 0 and maxTransformFeedbackBufferDataStride (%" PRIu32 ").",
6347 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006348 }
6349
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006350 if ((counterOffset % 4) != 0) {
sfricke-samsung6886c4b2021-01-16 08:37:35 -08006351 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006352 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu32 ") must be a multiple of 4.", counterOffset);
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07006353 }
6354
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07006355 return skip;
6356}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006357
6358bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
6359 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6360 const VkAllocationCallbacks *pAllocator,
6361 VkSamplerYcbcrConversion *pYcbcrConversion,
6362 const char *apiName) const {
6363 bool skip = false;
6364
6365 // Check samplerYcbcrConversion feature is set
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006366 const auto *ycbcr_features = LvlFindInChain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006367 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006368 const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006369 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
6370 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07006371 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02006372 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006373 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006374
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006375#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006376 const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(pCreateInfo);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006377 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006378#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006379 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006380#endif
6381
sfricke-samsung1a72f942020-07-25 12:09:18 -07006382 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006383
6384 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006385 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006386 const VkComponentMapping components = pCreateInfo->components;
6387 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
6388 if (FormatIsXChromaSubsampled(format) == true) {
6389 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
6390 skip |=
6391 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07006392 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
6393 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006394 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006395 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006396
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006397 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6398 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
6399 skip |= LogError(
6400 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
6401 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
6402 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
6403 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
6404 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006405
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006406 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6407 (components.r != VK_COMPONENT_SWIZZLE_B)) {
6408 skip |=
6409 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07006410 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
6411 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006412 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006413 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006414
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006415 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
6416 (components.b != VK_COMPONENT_SWIZZLE_R)) {
6417 skip |=
6418 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07006419 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
6420 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006421 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006422 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006423
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006424 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006425 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
6426 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
6427 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006428 skip |=
6429 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07006430 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
6431 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07006432 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
6433 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006434 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006435 }
6436
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006437 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
6438 // Checks same VU multiple ways in order to give a more useful error message
6439 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
6440 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
6441 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
6442 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
6443 skip |= LogError(
6444 device, vuid,
6445 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6446 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
6447 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6448 string_VkComponentSwizzle(components.b));
6449 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07006450
sfricke-samsunged028b02021-09-06 23:14:51 -07006451 // "must not correspond to a component which contains zero or one as a consequence of conversion to RGBA"
6452 // 4 component format = no issue
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006453 // 3 = no [a]
6454 // 2 = no [b,a]
6455 // 1 = no [g,b,a]
6456 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
sfricke-samsunged028b02021-09-06 23:14:51 -07006457 const uint32_t component_count = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatComponentCount(format);
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006458
sfricke-samsunged028b02021-09-06 23:14:51 -07006459 if ((component_count < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
6460 (components.b == VK_COMPONENT_SWIZZLE_A))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006461 skip |= LogError(device, vuid,
6462 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6463 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
6464 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6465 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006466 } else if ((component_count < 3) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006467 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
6468 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
6469 skip |= LogError(device, vuid,
6470 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6471 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
6472 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6473 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6474 string_VkComponentSwizzle(components.b));
sfricke-samsunged028b02021-09-06 23:14:51 -07006475 } else if ((component_count < 2) &&
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02006476 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
6477 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
6478 skip |= LogError(device, vuid,
6479 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
6480 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
6481 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
6482 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
6483 string_VkComponentSwizzle(components.b));
6484 }
sfricke-samsung83d98122020-07-04 06:21:15 -07006485 }
6486 }
6487
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08006488 return skip;
6489}
6490
6491bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
6492 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
6493 const VkAllocationCallbacks *pAllocator,
6494 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6495 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6496 "vkCreateSamplerYcbcrConversion");
6497}
6498
6499bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
6500 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
6501 VkSamplerYcbcrConversion *pYcbcrConversion) const {
6502 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
6503 "vkCreateSamplerYcbcrConversionKHR");
6504}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006505
6506bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
6507 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
6508 bool skip = false;
6509 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
6510 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
6511
6512 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07006513 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
6514 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
6515 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
6516 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
6517 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08006518 }
6519 return skip;
6520}
sourav parmara96ab1a2020-04-25 16:28:23 -07006521
6522bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006523 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006524 bool skip = false;
6525 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6526 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6527 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6528 }
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006529 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006530 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6531 skip |= LogError(
6532 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
6533 "vkCopyAccelerationStructureToMemoryKHR: The "
6534 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6535 }
6536 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
6537 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
6538 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
6539 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
6540 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
6541 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006542 return skip;
6543}
6544
6545bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
6546 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
6547 bool skip = false;
6548 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
6549 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
6550 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
6551 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
6552 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006553 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
6554 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006555 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006556 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07006557 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006558 return skip;
6559}
6560
6561bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
6562 const char *api_name) const {
6563 bool skip = false;
6564 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
6565 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
6566 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
6567 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
6568 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
6569 api_name);
6570 }
6571 return skip;
6572}
6573
6574bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006575 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006576 bool skip = false;
6577 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006578 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006579 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07006580 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07006581 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
6582 "vkCopyAccelerationStructureKHR: The "
6583 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006584 }
sourav parmara96ab1a2020-04-25 16:28:23 -07006585 return skip;
6586}
6587
6588bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
6589 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
6590 bool skip = false;
6591 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
6592 return skip;
6593}
6594
6595bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06006596 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006597 bool skip = false;
6598 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006599 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07006600 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
6601 }
6602 return skip;
6603}
6604
6605bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006606 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07006607 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006608 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006609 const auto *acc_struct_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006610 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
6611 skip |= LogError(
6612 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
6613 "vkCopyMemoryToAccelerationStructureKHR: The "
6614 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006615 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006616 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
6617 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07006618 return skip;
6619}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06006620
sourav parmara96ab1a2020-04-25 16:28:23 -07006621bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
6622 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
6623 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07006624 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07006625 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
6626 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06006627 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress (0x%" PRIx64 ") must be aligned to 256 bytes.",
sourav parmarcd5fb182020-07-17 12:58:44 -07006628 pInfo->src.deviceAddress);
6629 }
sourav parmar83c31b12020-05-06 12:30:54 -07006630 return skip;
6631}
6632bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
6633 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6634 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
6635 bool skip = false;
6636 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6637 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6638 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6639 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
6640 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6641 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6642 }
6643 return skip;
6644}
6645bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
6646 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
6647 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
6648 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006649 const auto *acc_structure_features = LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006650 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6651 skip |= LogError(
6652 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
6653 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
6654 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
6655 }
sourav parmar83c31b12020-05-06 12:30:54 -07006656 if (dataSize < accelerationStructureCount * stride) {
6657 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
6658 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07006659 "accelerationStructureCount (%" PRIu32 ") *stride(%zu).",
sourav parmar83c31b12020-05-06 12:30:54 -07006660 dataSize, accelerationStructureCount, stride);
6661 }
6662 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
6663 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
6664 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
6665 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
6666 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
6667 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
6668 }
6669 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
6670 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6671 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
6672 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6673 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
6674 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6675 stride);
6676 }
6677 }
6678 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
6679 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
6680 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
6681 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
6682 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
6683 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
6684 stride);
6685 }
6686 }
sourav parmar83c31b12020-05-06 12:30:54 -07006687 return skip;
6688}
6689bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
6690 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
6691 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006692 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006693 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
6694 skip |= LogError(
6695 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
6696 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
6697 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07006698 }
6699 return skip;
6700}
6701
6702bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07006703 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6704 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
6705 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6706 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07006707 uint32_t width, uint32_t height, uint32_t depth) const {
6708 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07006709 // RayGen
6710 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6711 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
6712 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006713 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006714 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6715 0) {
6716 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
6717 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6718 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6719 }
6720 // Callable
6721 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6722 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
6723 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6724 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006725 }
6726 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6727 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
6728 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006729 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6730 }
6731 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6732 0) {
6733 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
6734 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6735 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006736 }
6737 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006738 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6739 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
6740 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6741 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006742 }
6743 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6744 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006745 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
6746 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07006747 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006748 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6749 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
6750 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6751 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6752 }
sourav parmar83c31b12020-05-06 12:30:54 -07006753 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006754 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6755 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
6756 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
6757 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07006758 }
6759 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6760 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
6761 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07006762 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6763 }
6764 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6765 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
6766 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6767 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6768 }
6769 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
6770 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
6771 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
6772 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
6773 }
6774 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
6775 skip |=
6776 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
6777 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
6778 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07006779 }
6780
sourav parmarcd5fb182020-07-17 12:58:44 -07006781 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
6782 skip |=
6783 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
6784 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
6785 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
6786 }
6787
6788 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
6789 skip |=
6790 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
6791 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
6792 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07006793 }
6794 return skip;
6795}
6796
sourav parmarcd5fb182020-07-17 12:58:44 -07006797bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
6798 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
6799 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
6800 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006801 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006802 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07006803 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
6804 skip |= LogError(
6805 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
6806 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
6807 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07006808 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006809 // RayGen
6810 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
6811 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
6812 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07006813 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006814 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6815 0) {
6816 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
6817 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
6818 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6819 }
6820 // Callabe
6821 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6822 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
6823 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
6824 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006825 }
6826 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6827 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07006828 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
6829 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6830 }
6831 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
6832 0) {
6833 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
6834 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
6835 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006836 }
6837 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006838 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6839 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
6840 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
6841 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006842 }
6843 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6844 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07006845 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
6846 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07006847 }
sourav parmarcd5fb182020-07-17 12:58:44 -07006848 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6849 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
6850 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
6851 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
6852 }
sourav parmar83c31b12020-05-06 12:30:54 -07006853 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07006854 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
6855 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
6856 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
6857 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006858 }
6859 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
6860 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07006861 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
6862 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
6863 }
6864 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
6865 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
6866 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
6867 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07006868 }
6869
sourav parmarcd5fb182020-07-17 12:58:44 -07006870 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
6871 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
6872 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07006873 }
6874 return skip;
6875}
6876bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
6877 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
6878 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
6879 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
6880 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
6881 uint32_t width, uint32_t height, uint32_t depth) const {
6882 bool skip = false;
6883 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6884 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
6885 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
6886 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6887 }
6888 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6889 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
6890 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
6891 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6892 }
6893 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6894 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
6895 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
6896 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
6897 }
6898
6899 // hitShader
6900 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6901 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
6902 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
6903 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6904 }
6905 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6906 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
6907 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
6908 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6909 }
6910 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6911 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
6912 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
6913 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6914 }
6915
6916 // missShader
6917 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6918 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
6919 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
6920 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6921 }
6922 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
6923 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
6924 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
6925 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
6926 }
6927 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
6928 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
6929 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
6930 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
6931 }
6932
6933 // raygenShader
6934 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
6935 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
6936 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07006937 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
6938 }
6939 if (width > device_limits.maxComputeWorkGroupCount[0]) {
6940 skip |=
6941 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
6942 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
6943 }
6944 if (height > device_limits.maxComputeWorkGroupCount[1]) {
6945 skip |=
6946 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
6947 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
6948 }
6949 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
6950 skip |=
6951 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
6952 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07006953 }
6954 return skip;
6955}
6956
sourav parmar83c31b12020-05-06 12:30:54 -07006957bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07006958 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
6959 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07006960 bool skip = false;
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07006961 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6962 const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07006963 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
6964 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006965 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07006966 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
6967 }
6968 return skip;
6969}
6970
Piers Daniell39842ee2020-07-10 16:42:33 -06006971bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
6972 const VkViewport *pViewports) const {
6973 bool skip = false;
6974
6975 if (!physical_device_features.multiViewport) {
6976 if (viewportCount != 1) {
6977 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
6978 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
6979 ") is not 1.",
6980 viewportCount);
6981 }
6982 } else { // multiViewport enabled
6983 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
6984 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
6985 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
6986 ") must "
6987 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
6988 viewportCount, device_limits.maxViewports);
6989 }
6990 }
6991
6992 if (pViewports) {
6993 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
6994 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
6995 const char *fn_name = "vkCmdSetViewportWithCountEXT";
6996 skip |= manual_PreCallValidateViewport(
6997 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
6998 }
6999 }
7000
7001 return skip;
7002}
7003
7004bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
7005 const VkRect2D *pScissors) const {
7006 bool skip = false;
7007
7008 if (!physical_device_features.multiViewport) {
7009 if (scissorCount != 1) {
7010 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
7011 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7012 ") must "
7013 "be 1 when the multiViewport feature is disabled.",
7014 scissorCount);
7015 }
7016 } else { // multiViewport enabled
7017 if (scissorCount == 0) {
7018 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7019 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7020 ") must "
7021 "be great than zero.",
7022 scissorCount);
7023 } else if (scissorCount > device_limits.maxViewports) {
7024 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
7025 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
7026 ") must "
7027 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
7028 scissorCount, device_limits.maxViewports);
7029 }
7030 }
7031
7032 if (pScissors) {
7033 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
7034 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
7035
7036 if (scissor.offset.x < 0) {
7037 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7038 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
7039 scissor.offset.x);
7040 }
7041
7042 if (scissor.offset.y < 0) {
7043 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
7044 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
7045 scissor.offset.y);
7046 }
7047
7048 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
7049 if (x_sum > INT32_MAX) {
7050 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
7051 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7052 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7053 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
7054 }
7055
7056 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
7057 if (y_sum > INT32_MAX) {
7058 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
7059 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7060 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
7061 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
7062 }
7063 }
7064 }
7065
7066 return skip;
7067}
7068
7069bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
7070 uint32_t bindingCount, const VkBuffer *pBuffers,
7071 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
7072 const VkDeviceSize *pStrides) const {
7073 bool skip = false;
7074 if (firstBinding >= device_limits.maxVertexInputBindings) {
7075 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007076 "vkCmdBindVertexBuffers2EXT() firstBinding (%" PRIu32
7077 ") must be less than maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007078 firstBinding, device_limits.maxVertexInputBindings);
7079 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
7080 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007081 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%" PRIu32 ") and bindingCount (%" PRIu32
7082 ") must be less than "
7083 "maxVertexInputBindings (%" PRIu32 ")",
Piers Daniell39842ee2020-07-10 16:42:33 -06007084 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
7085 }
7086
7087 for (uint32_t i = 0; i < bindingCount; ++i) {
7088 if (pBuffers[i] == VK_NULL_HANDLE) {
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007089 const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
Piers Daniell39842ee2020-07-10 16:42:33 -06007090 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007091 skip |= LogError(
7092 commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
7093 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%" PRIu32 "] specified as VK_NULL_HANDLE", i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007094 } else {
7095 if (pOffsets[i] != 0) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007096 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
7097 "vkCmdBindVertexBuffers2EXT() pBuffers[%" PRIu32 "] is VK_NULL_HANDLE, but pOffsets[%" PRIu32
7098 "] is not 0",
7099 i, i);
Piers Daniell39842ee2020-07-10 16:42:33 -06007100 }
7101 }
7102 }
7103 if (pStrides) {
7104 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007105 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
7106 "vkCmdBindVertexBuffers2EXT() pStrides[%" PRIu32 "] (%" PRIu64
7107 ") must be less than maxVertexInputBindingStride (%" PRIu32 ")",
7108 i, pStrides[i], device_limits.maxVertexInputBindingStride);
Piers Daniell39842ee2020-07-10 16:42:33 -06007109 }
7110 }
7111 }
7112
7113 return skip;
7114}
sourav parmarcd5fb182020-07-17 12:58:44 -07007115
7116bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
7117 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
7118 bool skip = false;
7119 for (uint32_t i = 0; i < infoCount; ++i) {
7120 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
7121 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
7122 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
7123 }
7124 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
7125 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
7126 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
7127 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
7128 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
7129 api_name);
7130 }
7131 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
7132 skip |=
7133 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
7134 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
7135 }
7136 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
7137 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
7138 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
7139 }
7140 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
7141 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
7142 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
7143 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
7144 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
7145 api_name);
7146 }
7147 if (pInfos[i].pGeometries) {
7148 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7149 skip |= validate_ranged_enum(
7150 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
7151 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
7152 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7153 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007154 skip |= validate_struct_type(
7155 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
7156 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7157 &(pInfos[i].pGeometries[j].geometry.triangles),
7158 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7159 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7160 skip |= validate_struct_pnext(
7161 api_name,
7162 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7163 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7164 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7165 skip |=
7166 validate_ranged_enum(api_name,
7167 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
7168 ParameterName::IndexVector{i, j}),
7169 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
7170 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7171 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7172 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7173 &pInfos[i].pGeometries[j].geometry.triangles,
7174 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7175 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7176 skip |= validate_ranged_enum(
7177 api_name,
7178 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
7179 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
7180 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7181
7182 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
7183 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7184 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7185 }
7186 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7187 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7188 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7189 skip |=
7190 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7191 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7192 api_name);
7193 }
7194 }
7195 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7196 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7197 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7198 &pInfos[i].pGeometries[j].geometry.instances,
7199 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7200 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7201 skip |= validate_struct_type(
7202 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
7203 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7204 &(pInfos[i].pGeometries[j].geometry.instances),
7205 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7206 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7207 skip |= validate_struct_pnext(
7208 api_name,
7209 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7210 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7211 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7212
7213 skip |= validate_bool32(api_name,
7214 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
7215 ParameterName::IndexVector{i, j}),
7216 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
7217 }
7218 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7219 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7220 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7221 &pInfos[i].pGeometries[j].geometry.aabbs,
7222 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7223 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7224 skip |= validate_struct_type(
7225 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
7226 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7227 &(pInfos[i].pGeometries[j].geometry.aabbs),
7228 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7229 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7230 skip |= validate_struct_pnext(
7231 api_name,
7232 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7233 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7234 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7235 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
7236 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7237 "(%s):stride must be less than or equal to 2^32-1", api_name);
7238 }
7239 }
7240 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7241 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7242 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7243 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7244 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7245 api_name);
7246 }
7247 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7248 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7249 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7250 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7251 "of elements of"
7252 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7253 api_name);
7254 }
7255 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
7256 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7257 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7258 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7259 api_name);
7260 }
7261 }
7262 }
7263 }
7264 if (pInfos[i].ppGeometries != NULL) {
7265 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7266 skip |= validate_ranged_enum(
7267 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
7268 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
7269 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
7270 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007271 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
7272 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7273 &pInfos[i].ppGeometries[j]->geometry.triangles,
7274 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
7275 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
7276 skip |= validate_struct_type(
7277 api_name,
7278 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
7279 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
7280 &(pInfos[i].ppGeometries[j]->geometry.triangles),
7281 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
7282 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
7283 skip |= validate_struct_pnext(
7284 api_name,
7285 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
7286 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7287 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
7288 skip |= validate_ranged_enum(api_name,
7289 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
7290 ParameterName::IndexVector{i, j}),
7291 "VkFormat", AllVkFormatEnums,
7292 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
7293 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
7294 skip |= validate_ranged_enum(api_name,
7295 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
7296 ParameterName::IndexVector{i, j}),
7297 "VkIndexType", AllVkIndexTypeEnums,
7298 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
7299 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
7300 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
7301 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
7302 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
7303 }
7304 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
7305 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
7306 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
7307 skip |=
7308 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
7309 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
7310 api_name);
7311 }
7312 }
7313 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7314 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
7315 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7316 &pInfos[i].ppGeometries[j]->geometry.instances,
7317 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
7318 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
7319 skip |= validate_struct_type(
7320 api_name,
7321 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
7322 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
7323 &(pInfos[i].ppGeometries[j]->geometry.instances),
7324 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
7325 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
7326 skip |= validate_struct_pnext(
7327 api_name,
7328 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
7329 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7330 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
7331 skip |= validate_bool32(api_name,
7332 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
7333 ParameterName::IndexVector{i, j}),
7334 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
7335 }
7336 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7337 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
7338 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7339 &pInfos[i].ppGeometries[j]->geometry.aabbs,
7340 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
7341 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
7342 skip |= validate_struct_type(
7343 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
7344 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
7345 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
7346 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
7347 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
7348 skip |= validate_struct_pnext(
7349 api_name,
7350 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
7351 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
7352 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
7353 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
7354 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
7355 "(%s):stride must be less than or equal to 2^32-1", api_name);
7356 }
7357 }
7358 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
7359 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7360 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
7361 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
7362 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7363 api_name);
7364 }
7365 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
7366 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7367 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
7368 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
7369 "of elements of"
7370 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
7371 api_name);
7372 }
7373 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
7374 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
7375 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
7376 " member of each geometry in either pGeometries or ppGeometries must be the same.",
7377 api_name);
7378 }
7379 }
7380 }
7381 }
7382 }
7383 return skip;
7384}
7385bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
7386 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7387 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7388 bool skip = false;
7389 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
7390 for (uint32_t i = 0; i < infoCount; ++i) {
7391 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7392 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7393 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
7394 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
7395 "scratchData.deviceAddress member must be a multiple of "
7396 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7397 }
7398 for (uint32_t k = 0; k < infoCount; ++k) {
7399 if (i == k) continue;
7400 bool found = false;
7401 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007402 skip |=
7403 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7404 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%" PRIu32
7405 ") of pInfos must "
7406 "not be "
7407 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7408 ") of pInfos.",
7409 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007410 found = true;
7411 }
7412 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007413 skip |=
7414 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
7415 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%" PRIu32
7416 ") of pInfos must "
7417 "not be "
7418 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7419 ") of pInfos.",
7420 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007421 found = true;
7422 }
7423 if (found) break;
7424 }
7425 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7426 if (pInfos[i].pGeometries) {
7427 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7428 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7429 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7430 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7431 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7432 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7433 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7434 }
7435 } else {
7436 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7437 skip |=
7438 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7439 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7440 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7441 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7442 }
7443 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007444 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007445 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7446 skip |= LogError(
7447 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7448 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7449 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7450 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007451 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7452 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007453 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7454 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7455 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7456 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7457 }
7458 }
7459 } else if (pInfos[i].ppGeometries) {
7460 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7461 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7462 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7463 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
7464 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7465 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7466 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7467 }
7468 } else {
7469 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7470 skip |=
7471 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
7472 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7473 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7474 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7475 }
7476 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007477 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007478 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7479 skip |= LogError(
7480 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
7481 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
7482 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7483 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01007484 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7485 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007486 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
7487 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
7488 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7489 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7490 }
7491 }
7492 }
7493 }
7494 }
7495 return skip;
7496}
7497
7498bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
7499 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7500 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
7501 const uint32_t *const *ppMaxPrimitiveCounts) const {
7502 bool skip = false;
7503 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
7504 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007505 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007506 if (!ray_tracing_acceleration_structure_features ||
7507 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
7508 skip |= LogError(
7509 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
7510 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
7511 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
7512 }
7513 for (uint32_t i = 0; i < infoCount; ++i) {
sourav parmarcd5fb182020-07-17 12:58:44 -07007514 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
7515 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
7516 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
7517 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
7518 "scratchData.deviceAddress member must be a multiple of "
7519 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
7520 }
7521 for (uint32_t k = 0; k < infoCount; ++k) {
7522 if (i == k) continue;
7523 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007524 skip |= LogError(
7525 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
7526 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%" PRIu32
7527 ") "
7528 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
7529 "any other element [%" PRIu32 ") of pInfos.",
7530 i, k);
sourav parmarcd5fb182020-07-17 12:58:44 -07007531 break;
7532 }
7533 }
7534 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
7535 if (pInfos[i].pGeometries) {
7536 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7537 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
7538 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7539 skip |= LogError(
7540 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7541 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7542 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7543 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7544 }
7545 } else {
7546 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
7547 skip |= LogError(
7548 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7549 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7550 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7551 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7552 }
7553 }
7554 }
7555 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7556 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
7557 skip |= LogError(
7558 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7559 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7560 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7561 }
7562 }
7563 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7564 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
7565 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7566 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7567 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7568 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7569 }
7570 }
7571 } else if (pInfos[i].ppGeometries) {
7572 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
7573 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
7574 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7575 skip |= LogError(
7576 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
7577 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7578 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
7579 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
7580 }
7581 } else {
7582 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
7583 skip |= LogError(
7584 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
7585 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7586 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
7587 "geometry.data->deviceAddress must be aligned to 16 bytes.");
7588 }
7589 }
7590 }
7591 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
7592 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
7593 skip |= LogError(
7594 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
7595 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
7596 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
7597 }
7598 }
7599 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
7600 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
7601 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
7602 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
7603 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
7604 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
7605 }
7606 }
7607 }
7608 }
7609 }
7610 return skip;
7611}
7612
7613bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
7614 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
7615 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
7616 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
7617 bool skip = false;
7618 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
7619 const auto *ray_tracing_acceleration_structure_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007620 LvlFindInChain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007621 if (!ray_tracing_acceleration_structure_features ||
7622 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
7623 skip |=
7624 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
7625 "vkBuildAccelerationStructuresKHR: The "
7626 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
7627 }
7628 for (uint32_t i = 0; i < infoCount; ++i) {
7629 for (uint32_t j = 0; j < infoCount; ++j) {
7630 if (i == j) continue;
7631 bool found = false;
7632 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007633 skip |=
7634 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
7635 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%" PRIu32
7636 ") of pInfos must "
7637 "not be "
7638 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7639 ") of pInfos.",
7640 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007641 found = true;
7642 }
7643 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007644 skip |=
7645 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
7646 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%" PRIu32
7647 ") of pInfos must "
7648 "not be "
7649 "the same acceleration structure as the dstAccelerationStructure member of any other element (%" PRIu32
7650 ") of pInfos.",
7651 i, j);
sourav parmarcd5fb182020-07-17 12:58:44 -07007652 found = true;
7653 }
7654 if (found) break;
7655 }
7656 }
7657 return skip;
7658}
7659
7660bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
7661 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
7662 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
7663 bool skip = false;
7664 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
7665 const auto *ray_tracing_pipeline_features =
Mark Lobodzinski1f887d32020-12-30 15:31:33 -07007666 LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
7667 const auto *ray_query_features = LvlFindInChain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07007668 if (!(ray_tracing_pipeline_features || ray_query_features) ||
7669 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
7670 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
7671 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
Lars-Ivar Hesselberg Simonsendcd1e402021-11-23 17:14:03 +01007672 "vkGetAccelerationStructureBuildSizesKHR: The rayTracingPipeline or rayQuery feature must be enabled");
7673 }
7674 if (pBuildInfo != nullptr) {
7675 if (pBuildInfo->geometryCount != 0 && pMaxPrimitiveCounts == nullptr) {
7676 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619",
7677 "vkGetAccelerationStructureBuildSizesKHR: If pBuildInfo->geometryCount is not 0, pMaxPrimitiveCounts "
7678 "must be a valid pointer to an array of pBuildInfo->geometryCount uint32_t values");
7679 }
sourav parmarcd5fb182020-07-17 12:58:44 -07007680 }
7681 return skip;
7682}
sfricke-samsungecafb192021-01-17 08:21:14 -08007683
7684bool StatelessValidation::manual_PreCallValidateCreatePrivateDataSlotEXT(VkDevice device,
7685 const VkPrivateDataSlotCreateInfoEXT *pCreateInfo,
7686 const VkAllocationCallbacks *pAllocator,
7687 VkPrivateDataSlotEXT *pPrivateDataSlot) const {
7688 bool skip = false;
7689 const auto *private_data_features = LvlFindInChain<VkPhysicalDevicePrivateDataFeaturesEXT>(device_createinfo_pnext);
7690 if (private_data_features && private_data_features->privateData == VK_FALSE) {
7691 skip |= LogError(device, "VUID-vkCreatePrivateDataSlotEXT-privateData-04564",
7692 "vkCreatePrivateDataSlotEXT(): The privateData feature must be enabled.");
7693 }
7694 return skip;
Jeremy Gebbencbf22862021-03-03 12:01:22 -07007695}
Piers Daniellcb6d8032021-04-19 18:51:26 -06007696
7697bool StatelessValidation::manual_PreCallValidateCmdSetVertexInputEXT(
7698 VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount,
7699 const VkVertexInputBindingDescription2EXT *pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount,
7700 const VkVertexInputAttributeDescription2EXT *pVertexAttributeDescriptions) const {
7701 bool skip = false;
7702 const auto *vertex_input_dynamic_state_features =
7703 LvlFindInChain<VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT>(device_createinfo_pnext);
7704 const auto *vertex_attribute_divisor_features =
7705 LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(device_createinfo_pnext);
7706
7707 // VUID-vkCmdSetVertexInputEXT-None-04790
7708 if (!vertex_input_dynamic_state_features || vertex_input_dynamic_state_features->vertexInputDynamicState == VK_FALSE) {
7709 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-None-04790",
7710 "vkCmdSetVertexInputEXT(): The vertexInputDynamicState feature must be enabled.");
7711 }
7712
7713 // VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791
7714 if (vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
7715 skip |=
7716 LogError(device, "VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791",
7717 "vkCmdSetVertexInputEXT(): vertexBindingDescriptionCount is greater than the maxVertexInputBindings limit");
7718 }
7719
7720 // VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792
7721 if (vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
7722 skip |= LogError(
7723 device, "VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792",
7724 "vkCmdSetVertexInputEXT(): vertexAttributeDescriptionCount is greater than the maxVertexInputAttributes limit");
7725 }
7726
7727 // VUID-vkCmdSetVertexInputEXT-binding-04793
7728 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
7729 bool binding_found = false;
7730 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7731 if (pVertexAttributeDescriptions[attribute].binding == pVertexBindingDescriptions[binding].binding) {
7732 binding_found = true;
7733 break;
7734 }
7735 }
7736 if (!binding_found) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007737 skip |= LogError(
7738 device, "VUID-vkCmdSetVertexInputEXT-binding-04793",
7739 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32 "] references an unspecified binding", attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007740 }
7741 }
7742
7743 // VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794
7744 if (vertexBindingDescriptionCount > 1) {
7745 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount - 1; ++binding) {
7746 uint32_t binding_value = pVertexBindingDescriptions[binding].binding;
7747 for (uint32_t next_binding = binding + 1; next_binding < vertexBindingDescriptionCount; ++next_binding) {
7748 if (binding_value == pVertexBindingDescriptions[next_binding].binding) {
7749 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007750 "vkCmdSetVertexInputEXT(): binding description for binding %" PRIu32 " already specified",
7751 binding_value);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007752 }
7753 }
7754 }
7755 }
7756
7757 // VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795
7758 if (vertexAttributeDescriptionCount > 1) {
7759 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount - 1; ++attribute) {
7760 uint32_t location = pVertexAttributeDescriptions[attribute].location;
7761 for (uint32_t next_attribute = attribute + 1; next_attribute < vertexAttributeDescriptionCount; ++next_attribute) {
7762 if (location == pVertexAttributeDescriptions[next_attribute].location) {
7763 skip |= LogError(device, "VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007764 "vkCmdSetVertexInputEXT(): attribute description for location %" PRIu32 " already specified",
7765 location);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007766 }
7767 }
7768 }
7769 }
7770
7771 for (uint32_t binding = 0; binding < vertexBindingDescriptionCount; ++binding) {
7772 // VUID-VkVertexInputBindingDescription2EXT-binding-04796
7773 if (pVertexBindingDescriptions[binding].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007774 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-binding-04796",
7775 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7776 "].binding is greater than maxVertexInputBindings",
7777 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007778 }
7779
7780 // VUID-VkVertexInputBindingDescription2EXT-stride-04797
7781 if (pVertexBindingDescriptions[binding].stride > device_limits.maxVertexInputBindingStride) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007782 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-stride-04797",
7783 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7784 "].stride is greater than maxVertexInputBindingStride",
7785 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007786 }
7787
7788 // VUID-VkVertexInputBindingDescription2EXT-divisor-04798
7789 if (pVertexBindingDescriptions[binding].divisor == 0 &&
7790 (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateZeroDivisor)) {
7791 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04798",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007792 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7793 "].divisor is zero but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007794 "vertexAttributeInstanceRateZeroDivisor is not enabled",
7795 binding);
7796 }
7797
7798 if (pVertexBindingDescriptions[binding].divisor > 1) {
7799 // VUID-VkVertexInputBindingDescription2EXT-divisor-04799
7800 if (!vertex_attribute_divisor_features || !vertex_attribute_divisor_features->vertexAttributeInstanceRateDivisor) {
7801 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-04799",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007802 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7803 "].divisor is greater than one but "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007804 "vertexAttributeInstanceRateDivisor is not enabled",
7805 binding);
7806 } else {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007807 // VUID-VkVertexInputBindingDescription2EXT-divisor-06226
Piers Daniellcb6d8032021-04-19 18:51:26 -06007808 if (pVertexBindingDescriptions[binding].divisor >
7809 phys_dev_ext_props.vertex_attribute_divisor_props.maxVertexAttribDivisor) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007810 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06226",
7811 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7812 "].divisor is greater than maxVertexAttribDivisor",
7813 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007814 }
7815
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007816 // VUID-VkVertexInputBindingDescription2EXT-divisor-06227
Piers Daniellcb6d8032021-04-19 18:51:26 -06007817 if (pVertexBindingDescriptions[binding].inputRate != VK_VERTEX_INPUT_RATE_INSTANCE) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007818 skip |= LogError(device, "VUID-VkVertexInputBindingDescription2EXT-divisor-06227",
7819 "vkCmdSetVertexInputEXT(): pVertexBindingDescriptions[%" PRIu32
7820 "].divisor is greater than 1 but inputRate "
7821 "is not VK_VERTEX_INPUT_RATE_INSTANCE",
7822 binding);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007823 }
7824 }
7825 }
7826 }
7827
7828 for (uint32_t attribute = 0; attribute < vertexAttributeDescriptionCount; ++attribute) {
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007829 // VUID-VkVertexInputAttributeDescription2EXT-location-06228
Piers Daniellcb6d8032021-04-19 18:51:26 -06007830 if (pVertexAttributeDescriptions[attribute].location > device_limits.maxVertexInputAttributes) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007831 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-location-06228",
7832 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7833 "].location is greater than maxVertexInputAttributes",
7834 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007835 }
7836
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007837 // VUID-VkVertexInputAttributeDescription2EXT-binding-06229
Piers Daniellcb6d8032021-04-19 18:51:26 -06007838 if (pVertexAttributeDescriptions[attribute].binding > device_limits.maxVertexInputBindings) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007839 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-binding-06229",
7840 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7841 "].binding is greater than maxVertexInputBindings",
7842 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007843 }
7844
Mike Schuchardt7b152fa2021-08-03 16:30:27 -07007845 // VUID-VkVertexInputAttributeDescription2EXT-offset-06230
Piers Daniellcb6d8032021-04-19 18:51:26 -06007846 if (pVertexAttributeDescriptions[attribute].offset > device_limits.maxVertexInputAttributeOffset) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007847 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-offset-06230",
7848 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7849 "].offset is greater than maxVertexInputAttributeOffset",
7850 attribute);
Piers Daniellcb6d8032021-04-19 18:51:26 -06007851 }
7852
7853 // VUID-VkVertexInputAttributeDescription2EXT-format-04805
7854 VkFormatProperties properties;
7855 DispatchGetPhysicalDeviceFormatProperties(physical_device, pVertexAttributeDescriptions[attribute].format, &properties);
7856 if ((properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) == 0) {
7857 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription2EXT-format-04805",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007858 "vkCmdSetVertexInputEXT(): pVertexAttributeDescriptions[%" PRIu32
7859 "].format is not a "
Piers Daniellcb6d8032021-04-19 18:51:26 -06007860 "VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT supported format",
7861 attribute);
7862 }
7863 }
7864
7865 return skip;
7866}
sfricke-samsung51303fb2021-05-09 19:09:13 -07007867
7868bool StatelessValidation::manual_PreCallValidateCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
7869 VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
7870 const void *pValues) const {
7871 bool skip = false;
7872 const uint32_t max_push_constants_size = device_limits.maxPushConstantsSize;
7873 // Check that offset + size don't exceed the max.
7874 // Prevent arithetic overflow here by avoiding addition and testing in this order.
7875 if (offset >= max_push_constants_size) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007876 skip |=
7877 LogError(device, "VUID-vkCmdPushConstants-offset-00370",
7878 "vkCmdPushConstants(): offset (%" PRIu32 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
7879 offset, max_push_constants_size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007880 }
7881 if (size > max_push_constants_size - offset) {
7882 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00371",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007883 "vkCmdPushConstants(): offset (%" PRIu32 ") and size (%" PRIu32
7884 ") that exceeds this device's maxPushConstantSize of %" PRIu32 ".",
sfricke-samsung51303fb2021-05-09 19:09:13 -07007885 offset, size, max_push_constants_size);
7886 }
7887
7888 // size needs to be non-zero and a multiple of 4.
7889 if (size & 0x3) {
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007890 skip |= LogError(device, "VUID-vkCmdPushConstants-size-00369",
7891 "vkCmdPushConstants(): size (%" PRIu32 ") must be a multiple of 4.", size);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007892 }
7893
7894 // offset needs to be a multiple of 4.
7895 if ((offset & 0x3) != 0) {
7896 skip |= LogError(device, "VUID-vkCmdPushConstants-offset-00368",
sfricke-samsunga3d4fc12021-09-28 22:25:46 -07007897 "vkCmdPushConstants(): offset (%" PRIu32 ") must be a multiple of 4.", offset);
sfricke-samsung51303fb2021-05-09 19:09:13 -07007898 }
7899 return skip;
Jeremy Gebbenda6b48f2021-05-13 10:46:18 -06007900}
ziga-lunargb1dd8a22021-07-15 17:47:19 +02007901
7902bool StatelessValidation::manual_PreCallValidateMergePipelineCaches(VkDevice device, VkPipelineCache dstCache,
7903 uint32_t srcCacheCount,
7904 const VkPipelineCache *pSrcCaches) const {
7905 bool skip = false;
7906 if (pSrcCaches) {
7907 for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
7908 if (pSrcCaches[index0] == dstCache) {
7909 skip |= LogError(instance, "VUID-vkMergePipelineCaches-dstCache-00770",
7910 "vkMergePipelineCaches(): dstCache %s is in pSrcCaches list.",
7911 report_data->FormatHandle(dstCache).c_str());
7912 break;
7913 }
7914 }
7915 }
7916 return skip;
7917}
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007918
7919bool StatelessValidation::manual_PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image,
7920 VkImageLayout imageLayout, const VkClearColorValue *pColor,
7921 uint32_t rangeCount,
7922 const VkImageSubresourceRange *pRanges) const {
7923 bool skip = false;
7924 if (!pColor) {
7925 skip |=
7926 LogError(commandBuffer, "VUID-vkCmdClearColorImage-pColor-04961", "vkCmdClearColorImage(): pColor must not be null");
7927 }
7928 return skip;
7929}
7930
7931bool StatelessValidation::ValidateCmdBeginRenderPass(const char *const func_name,
7932 const VkRenderPassBeginInfo *const rp_begin) const {
7933 bool skip = false;
7934 if ((rp_begin->clearValueCount != 0) && !rp_begin->pClearValues) {
7935 skip |= LogError(rp_begin->renderPass, "VUID-VkRenderPassBeginInfo-clearValueCount-04962",
7936 "%s: VkRenderPassBeginInfo::clearValueCount != 0 (%" PRIu32
ziga-lunarg47109fb2021-09-03 18:41:12 +02007937 "), but VkRenderPassBeginInfo::pClearValues is null.",
Nathaniel Cesario298d3cb2021-08-03 13:49:02 -06007938 func_name, rp_begin->clearValueCount);
7939 }
7940 return skip;
7941}
7942
7943bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7944 VkSubpassContents) const {
7945 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass", pRenderPassBegin);
7946 return skip;
7947}
7948
7949bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer,
7950 const VkRenderPassBeginInfo *pRenderPassBegin,
7951 const VkSubpassBeginInfo *) const {
7952 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2KHR", pRenderPassBegin);
7953 return skip;
7954}
7955
7956bool StatelessValidation::manual_PreCallValidateCmdBeginRenderPass2(VkCommandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin,
7957 const VkSubpassBeginInfo *) const {
7958 bool skip = ValidateCmdBeginRenderPass("vkCmdBeginRenderPass2", pRenderPassBegin);
7959 return skip;
7960}
ziga-lunargc7bb56a2021-08-10 09:28:52 +02007961
7962bool StatelessValidation::manual_PreCallValidateCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,
7963 uint32_t firstDiscardRectangle,
7964 uint32_t discardRectangleCount,
7965 const VkRect2D *pDiscardRectangles) const {
7966 bool skip = false;
7967
7968 if (pDiscardRectangles) {
7969 for (uint32_t i = 0; i < discardRectangleCount; ++i) {
7970 const int64_t x_sum =
7971 static_cast<int64_t>(pDiscardRectangles[i].offset.x) + static_cast<int64_t>(pDiscardRectangles[i].extent.width);
7972 if (x_sum > std::numeric_limits<int32_t>::max()) {
7973 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00588",
7974 "vkCmdSetDiscardRectangleEXT(): offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7975 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7976 pDiscardRectangles[i].offset.x, pDiscardRectangles[i].extent.width, x_sum, i);
7977 }
7978
7979 const int64_t y_sum =
7980 static_cast<int64_t>(pDiscardRectangles[i].offset.y) + static_cast<int64_t>(pDiscardRectangles[i].extent.height);
7981 if (y_sum > std::numeric_limits<int32_t>::max()) {
7982 skip |= LogError(device, "VUID-vkCmdSetDiscardRectangleEXT-offset-00589",
7983 "vkCmdSetDiscardRectangleEXT(): offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
7984 ") of pDiscardRectangles[%" PRIu32 "] will overflow int32_t.",
7985 pDiscardRectangles[i].offset.y, pDiscardRectangles[i].extent.height, y_sum, i);
7986 }
7987 }
7988 }
7989
7990 return skip;
7991}
ziga-lunarg3c37dfb2021-08-24 12:51:07 +02007992
7993bool StatelessValidation::manual_PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery,
7994 uint32_t queryCount, size_t dataSize, void *pData,
7995 VkDeviceSize stride, VkQueryResultFlags flags) const {
7996 bool skip = false;
7997
7998 if ((flags & VK_QUERY_RESULT_WITH_STATUS_BIT_KHR) && (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT)) {
7999 skip |= LogError(device, "VUID-vkGetQueryPoolResults-flags-04811",
8000 "vkGetQueryPoolResults(): flags include both VK_QUERY_RESULT_WITH_STATUS_BIT_KHR bit and VK_QUERY_RESULT_WITH_AVAILABILITY_BIT bit.");
8001 }
8002
8003 return skip;
8004}
ziga-lunargcf340c42021-08-19 00:13:38 +02008005
8006bool StatelessValidation::manual_PreCallValidateCmdBeginConditionalRenderingEXT(
8007 VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin) const {
8008 bool skip = false;
8009
8010 if ((pConditionalRenderingBegin->offset & 3) != 0) {
8011 skip |= LogError(commandBuffer, "VUID-VkConditionalRenderingBeginInfoEXT-offset-01984",
8012 "vkCmdBeginConditionalRenderingEXT(): pConditionalRenderingBegin->offset (%" PRIu64
8013 ") is not a multiple of 4.",
8014 pConditionalRenderingBegin->offset);
8015 }
8016
8017 return skip;
Jeremy Gebben2e5b41b2021-10-11 16:41:49 -06008018}